Submission #1331602
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair <ll,ll> P; int N; vector<P> a; int main() { cin >> N; for(int i = 0; i < N; i++) { ll A, B; cin >> A >> B; a.push_back(P(A,B)); } sort(a.begin(), a.end(), greater<P> ()); ll ans = 0; ll k = 0; for(int i = 0; i < a.size(); i++) { ll tmp = a[i].first + k; ll tmp2 = 0; if(tmp / a[i].second == 0) { ans += a[i].second - tmp; k += a[i].second - tmp; } else { if(tmp % a[i].second != 0) tmp2++; tmp2 += tmp / a[i].second; ans += tmp2 * a[i].second - tmp; k += tmp2 * a[i].second - tmp; } } cout << ans <<endl; }
Submission Info
Submission Time | |
---|---|
Task | A - Multiple Array |
User | shossie1016 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 742 Byte |
Status | WA |
Exec Time | 92 ms |
Memory | 2420 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 300 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, s1.txt, s2.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | WA | 87 ms | 2420 KB |
02.txt | WA | 88 ms | 2420 KB |
03.txt | WA | 88 ms | 2420 KB |
04.txt | WA | 88 ms | 2420 KB |
05.txt | WA | 87 ms | 2420 KB |
06.txt | WA | 88 ms | 2420 KB |
07.txt | AC | 65 ms | 2420 KB |
08.txt | WA | 90 ms | 2420 KB |
09.txt | WA | 70 ms | 2420 KB |
10.txt | WA | 92 ms | 2420 KB |
11.txt | AC | 59 ms | 2420 KB |
12.txt | WA | 38 ms | 2420 KB |
13.txt | AC | 59 ms | 2420 KB |
14.txt | AC | 89 ms | 2420 KB |
15.txt | WA | 1 ms | 256 KB |
16.txt | WA | 1 ms | 256 KB |
s1.txt | WA | 1 ms | 256 KB |
s2.txt | AC | 1 ms | 256 KB |