Submission #1074506


Source Code Expand

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

int n;
ll a[100100], b[100100];

int main(){
	ll ans = 0, buf = 0;
	cin >> n;
	REP(i, n){
		cin >> a[i] >> b[i];
	}
	for (int i = n - 1; i >= 0; i--){
		if (b[i] == 1)continue;
		if (a[i] % b[i] == 0)continue;
		ans += ((a[i] + buf) / b[i] + 1)*b[i] - (a[i] + buf);
		buf = ans;
	}
	cout << ans << endl;
}

Submission Info

Submission Time
Task A - Multiple Array
User jimmy
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1164 Byte
Status WA
Exec Time 147 ms
Memory 1792 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 117 ms 1792 KB
02.txt AC 122 ms 1792 KB
03.txt AC 134 ms 1792 KB
04.txt AC 133 ms 1792 KB
05.txt AC 133 ms 1792 KB
06.txt AC 130 ms 1792 KB
07.txt AC 84 ms 1792 KB
08.txt AC 141 ms 1792 KB
09.txt AC 74 ms 1792 KB
10.txt AC 141 ms 1792 KB
11.txt WA 84 ms 1792 KB
12.txt AC 37 ms 1792 KB
13.txt WA 88 ms 1792 KB
14.txt AC 147 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