Submission #1073729
Source Code Expand
#include<iostream> #include<iomanip> #include<map> #include<unordered_map> #include<set> #include<unordered_set> #include<vector> #include<array> #include<string> #include<stack> #include<queue> #include<algorithm> #include<cassert> #include<functional> #include<random> #include<complex> #include<bitset> #include<chrono> //#include<boost/multiprecision/cpp_int.hpp> #define int int64_t #define uint uint64_t #define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++) #define rep(i, a) REP(i, 0, a) #define SZ(X) ((int64_t)((X).size())) #define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++) #define ALL(a) (a.begin()), (a.end()) #define HAS(a, x) (a.find(x) != a.end()) #define Min(x) *min_element(ALL(x)) #define Max(x) *max_element(ALL(x)) #define Unique(L) (L.erase(unique(ALL(L)), L.end())) #define intmax (std::numeric_limits<int64_t>::max() / 4) #define doublemax (std::numeric_limits<double>::max() / 4) using namespace std; //typedef boost::multiprecision::cpp_int bigint; const double EPS = 1e-9; const double PI = acos(-1.0); //sort(ALL(v),greater<int>()); signed main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector<int>A(N), B(N); rep(i, N) { cin >> A[i] >> B[i]; } int ans = 0; for (int i = N - 1; 0 <= i; i--) { A[i] += ans; if (A[i] == 0)continue; if (A[i] <= B[i]) { ans += B[i] - A[i]; continue; } if (A[i] % B[i] == 0)continue; A[i] %= B[i]; ans += B[i] - A[i]; } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Multiple Array |
User | eukaryo |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 1570 Byte |
Status | AC |
Exec Time | 28 ms |
Memory | 1792 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 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 | AC | 26 ms | 1792 KB |
02.txt | AC | 26 ms | 1792 KB |
03.txt | AC | 26 ms | 1792 KB |
04.txt | AC | 26 ms | 1792 KB |
05.txt | AC | 27 ms | 1792 KB |
06.txt | AC | 26 ms | 1792 KB |
07.txt | AC | 21 ms | 1792 KB |
08.txt | AC | 27 ms | 1792 KB |
09.txt | AC | 20 ms | 1792 KB |
10.txt | AC | 28 ms | 1792 KB |
11.txt | AC | 21 ms | 1792 KB |
12.txt | AC | 15 ms | 1792 KB |
13.txt | AC | 21 ms | 1792 KB |
14.txt | AC | 27 ms | 1792 KB |
15.txt | AC | 3 ms | 256 KB |
16.txt | AC | 2 ms | 256 KB |
s1.txt | AC | 2 ms | 256 KB |
s2.txt | AC | 3 ms | 256 KB |