Submission #1073419


Source Code Expand

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve(ll N, vector<ll> A, vector<ll> B) {
  ll c = 0;
  for (int i = N - 1; i >= 0; --i) {
    ll a = A[i] + c;
    ll r = (-a % B[i] + B[i]) % B[i];
    c += r;
  }
  cout << c << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	scanf("%lld", &N);
	vector<ll> A(N-1+1);
	vector<ll> B(N-1+1);
	for (int i = 0 ; i <= N-1 ; i++) {
	  scanf("%lld", &A[i]);
	  scanf("%lld", &B[i]);
	}
	solve(N, A, B);
	return 0;
}

Submission Info

Submission Time
Task A - Multiple Array
User asi1024
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1808 Byte
Status AC
Exec Time 33 ms
Memory 3328 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:70:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &N);
                   ^
./Main.cpp:74:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    scanf("%lld", &A[i]);
                        ^
./Main.cpp:75:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    scanf("%lld", &B[i]);
                        ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 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 AC 31 ms 3328 KB
02.txt AC 32 ms 3328 KB
03.txt AC 32 ms 3328 KB
04.txt AC 32 ms 3328 KB
05.txt AC 32 ms 3328 KB
06.txt AC 32 ms 3328 KB
07.txt AC 27 ms 3328 KB
08.txt AC 32 ms 3328 KB
09.txt AC 27 ms 3328 KB
10.txt AC 33 ms 3328 KB
11.txt AC 27 ms 3328 KB
12.txt AC 23 ms 3328 KB
13.txt AC 27 ms 3328 KB
14.txt AC 33 ms 3328 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