Submission #2404774


Source Code Expand

#include <bits/stdc++.h>

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define REP(i, n) for(LL i = 0; i < n; ++i)
#define FOR(i, a, n) for(LL i = a; i < n; ++i)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

#define int long long

/*************** using variables ***************/
int n;
vector<int> a, b, neces;
LL ans = 0;
/**********************************************/

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n;
    a.assign(n, 0);
    b.assign(n, 0);
    neces.assign(n, 0);

    REP(i, n) cin >> a[i] >> b[i];
    
    for(int i = n-1; i >= 0; i--){
        neces[i] = (a[i] % b[i] == 0 ? 0 : b[i] - (ans + a[i]) % b[i]);
        ans += neces[i];
    }
    cout << ans << endl;
}

Submission Info

Submission Time
Task A - Multiple Array
User wheson
Language C++14 (GCC 5.4.1)
Score 0
Code Size 982 Byte
Status WA
Exec Time 24 ms
Memory 2688 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 2
AC × 16
WA × 2
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 2688 KB
02.txt AC 23 ms 2560 KB
03.txt AC 23 ms 2560 KB
04.txt AC 23 ms 2560 KB
05.txt AC 23 ms 2560 KB
06.txt AC 23 ms 2560 KB
07.txt AC 19 ms 2560 KB
08.txt AC 24 ms 2560 KB
09.txt AC 18 ms 2560 KB
10.txt AC 24 ms 2560 KB
11.txt WA 19 ms 2560 KB
12.txt AC 14 ms 2560 KB
13.txt WA 19 ms 2560 KB
14.txt AC 23 ms 2560 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