Please sign in first.
Submission #1076449
Source Code Expand
#include <iostream>
#include <algorithm>
#include <vector>
#include <fstream>
#include <string>
#include <sstream>
#include <math.h>
#include <set>
#include <map>
using namespace std;
#define rep(i,n) for(int i = 0; i < n ; i++)
#define pb push_back
static const int INF = 1000000;
static const int MAX = 100000;
typedef pair<int, int> P;
typedef pair<P, int> PP;
int main(void){
int N; cin >> N;
long long int a[MAX],b[MAX];
long long int x,y;
rep(i,N){
cin >> x >> y;
a[i] = x; b[i] = y;
}
float result = 0;
long long int res = 0;
for(int i = N - 1; i >= 0; i--){
//cout << ceil((a[i] + result) / b[i]) << endl;
//cout << b[i] << " " << a[i] <<endl;
res = (ceil(((float)a[i] + (float)res) / (float)b[i]) * b[i]) - a[i];
//cout << "i = " << i << " " << result << endl;
}
cout << res << endl;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | A - Multiple Array |
| User | imitation0813 |
| Language | C++14 (GCC 5.4.1) |
| Score | 0 |
| Code Size | 900 Byte |
| Status | WA |
| Exec Time | 101 ms |
| Memory | 1792 KiB |
Judge Result
| Set Name | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 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 | WA | 85 ms | 1792 KiB |
| 02.txt | WA | 82 ms | 1792 KiB |
| 03.txt | WA | 83 ms | 1792 KiB |
| 04.txt | WA | 82 ms | 1792 KiB |
| 05.txt | WA | 83 ms | 1792 KiB |
| 06.txt | WA | 82 ms | 1792 KiB |
| 07.txt | AC | 59 ms | 1792 KiB |
| 08.txt | WA | 101 ms | 1792 KiB |
| 09.txt | AC | 63 ms | 1792 KiB |
| 10.txt | WA | 86 ms | 1792 KiB |
| 11.txt | AC | 60 ms | 1792 KiB |
| 12.txt | AC | 36 ms | 1792 KiB |
| 13.txt | WA | 60 ms | 1792 KiB |
| 14.txt | AC | 89 ms | 1792 KiB |
| 15.txt | AC | 3 ms | 256 KiB |
| 16.txt | AC | 3 ms | 256 KiB |
| s1.txt | AC | 3 ms | 256 KiB |
| s2.txt | AC | 3 ms | 256 KiB |