Submission #1073387


Source Code Expand

Copy
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

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

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	int N;
	cin >> N;

	vector<int> A(N), B(N);

	rep(i, N) {
		cin >> A[i] >> B[i];
	}

	int ret = 0;
	for (int i = N - 1; i >= 0; i--) {
		int tmp = B[i] - (A[i] + ret) % B[i];
		if (tmp < B[i]) ret += tmp;
	}

	cout << ret << endl;

    return 0;
}

Submission Info

Submission Time
Task A - Multiple Array
User iwashi31
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1208 Byte
Status
Exec Time 90 ms
Memory 1920 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
× 2
× 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 84 ms 1792 KB
02.txt 83 ms 1920 KB
03.txt 83 ms 1792 KB
04.txt 84 ms 1792 KB
05.txt 83 ms 1792 KB
06.txt 83 ms 1792 KB
07.txt 63 ms 1792 KB
08.txt 87 ms 1792 KB
09.txt 61 ms 1792 KB
10.txt 87 ms 1792 KB
11.txt 61 ms 1792 KB
12.txt 37 ms 1920 KB
13.txt 61 ms 1792 KB
14.txt 90 ms 1792 KB
15.txt 3 ms 256 KB
16.txt 3 ms 256 KB
s1.txt 3 ms 384 KB
s2.txt 3 ms 256 KB