Submission #5494336
Source Code Expand
#include <bits/stdc++.h> #define pb push_back #define ppb pop_back #define fi first #define se second #define mid ((x + y) / 2) #define left (ind * 2) #define right (ind * 2 + 1) #define mp make_pair #define timer ((double)clock() / CLOCKS_PER_SEC) #define endl "\n" #define spc " " #define d1(x) cerr<<#x<<":"<<x<<endl #define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl #define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl #define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) using namespace std; typedef long long int lli; typedef pair<int, int> ii; typedef pair<ii, int> iii; typedef pair<double, double> dd; const int N = (int)(1e6 + 5); const int LOG = (int)(20); lli n, a[N], b[N], atl, ans; int main() { fast_io(); // freopen("inp.in", "r", stdin); cin >> n; for(int i = 1; i <= n; i++) cin >> a[i] >> b[i]; lli atl = 0; for(int i = n; i >= 1; i--) { b[i] *= ceil((double)(a[i] + atl) / b[i]); ans += b[i] - a[i] - atl; atl = b[i] - a[i]; } cout << ans; }
Submission Info
Submission Time | |
---|---|
Task | A - Multiple Array |
User | Kewo |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 1079 Byte |
Status | AC |
Exec Time | 24 ms |
Memory | 5120 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 | 24 ms | 5120 KB |
02.txt | AC | 22 ms | 5120 KB |
03.txt | AC | 22 ms | 5120 KB |
04.txt | AC | 22 ms | 5120 KB |
05.txt | AC | 22 ms | 5120 KB |
06.txt | AC | 22 ms | 5120 KB |
07.txt | AC | 18 ms | 5120 KB |
08.txt | AC | 23 ms | 5120 KB |
09.txt | AC | 18 ms | 5120 KB |
10.txt | AC | 23 ms | 5120 KB |
11.txt | AC | 18 ms | 5120 KB |
12.txt | AC | 14 ms | 5120 KB |
13.txt | AC | 18 ms | 5120 KB |
14.txt | AC | 23 ms | 5120 KB |
15.txt | AC | 2 ms | 2304 KB |
16.txt | AC | 2 ms | 2304 KB |
s1.txt | AC | 2 ms | 2304 KB |
s2.txt | AC | 2 ms | 2304 KB |