Submission #1216627


Source Code Expand

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
 
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
 
using namespace std;
 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
 
const int MOD = 1000000007;
 
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;
 
signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);
 
    int n;
    cin >> n;
    VI a(n), b(n);
    REP(i, n) {
        cin >> a[i] >> b[i];
    }
 
    int ans = 0;
    for (int i = n - 1; i >= 0; --i) {
        int ta = a[i] + ans;
        int tb = b[i];
        if ((ta % tb) != 0) {
            ans += tb - (ta % tb);
        }
    }
 
    cout << ans << endl;
 
    return 0;
}

Submission Info

Submission Time
Task A - Multiple Array
User NSTomoS
Language C++14 (Clang 3.8.0)
Score 300
Code Size 1556 Byte
Status AC
Exec Time 216 ms
Memory 1792 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 18
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 214 ms 1792 KB
02.txt AC 214 ms 1792 KB
03.txt AC 214 ms 1792 KB
04.txt AC 214 ms 1792 KB
05.txt AC 214 ms 1792 KB
06.txt AC 214 ms 1792 KB
07.txt AC 153 ms 1792 KB
08.txt AC 216 ms 1792 KB
09.txt AC 153 ms 1792 KB
10.txt AC 216 ms 1792 KB
11.txt AC 147 ms 1792 KB
12.txt AC 90 ms 1792 KB
13.txt AC 147 ms 1792 KB
14.txt AC 214 ms 1792 KB
15.txt AC 1 ms 256 KB
16.txt AC 1 ms 256 KB
s1.txt AC 1 ms 256 KB
s2.txt AC 1 ms 256 KB