AtCoder Grand Contest 009

Submission #1073453

Source codeソースコード

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

int main() {
  int n;
  scanf("%d", &n);
  vll a(n), b(n);
  rep (i, n) {
    scanf("%lld %lld", &a[i], &b[i]);
  }
  ll cnt = 0;
  for (int i = n-1; i >= 0; --i) {
    ll r = (a[i] + cnt) % b[i];
    if (r == 0) {
      continue;
    }
    cnt += (b[i] - r);
  }
  printf("%lld\n", cnt);
  return 0;
}

Submission

Task問題 A - Multiple Array
User nameユーザ名 gosenoku
Created time投稿日時
Language言語 C++14 (Clang 3.8.0)
Status状態 AC
Score得点 300
Source lengthソースコード長 1218 Byte
File nameファイル名
Exec time実行時間 28 ms
Memory usageメモリ使用量 1792 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - s1.txt,s2.txt
All 300 / 300 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01.txt AC 27 ms 1792 KB
02.txt AC 28 ms 1792 KB
03.txt AC 28 ms 1792 KB
04.txt AC 28 ms 1792 KB
05.txt AC 28 ms 1792 KB
06.txt AC 28 ms 1792 KB
07.txt AC 23 ms 1792 KB
08.txt AC 28 ms 1792 KB
09.txt AC 23 ms 1792 KB
10.txt AC 28 ms 1792 KB
11.txt AC 23 ms 1792 KB
12.txt AC 19 ms 1792 KB
13.txt AC 23 ms 1792 KB
14.txt AC 28 ms 1792 KB
15.txt AC 3 ms 256 KB
16.txt AC 3 ms 256 KB
s1.txt AC 3 ms 256 KB
s2.txt AC 3 ms 256 KB