Submission #441399

# Submission time Handle Problem Language Result Execution time Memory
441399 2021-07-05T06:46:13 Z peijar Remittance (JOI19_remittance) C++17
0 / 100
1 ms 204 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int N;
  cin >> N;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i] >> B[i];
  }
  long double fdelta1 = A[0] - B[0];
  long double pow2 = 1 / 4.;
  for (int i = N - 1; i > 0; --i, pow2 /= 2.)
    fdelta1 += (A[i] - B[i]) * pow2;
  pow2 = 1 - powl(1 / 2., N - 1);
  fdelta1 /= pow2;
  vector<int> delta(N);
  delta[0] = roundl(fdelta1);
  for (int i = 1; i < N; ++i) {
    delta[i] = (A[i] - B[i] + delta[i - 1]) / 2;
  }
  for (int i = 0; i < N; ++i) {
    if (delta[i] < 0 or
        A[i] - 2 * delta[i] + delta[i ? i - 1 : N - 1] != B[i]) {
      cout << "No\n";
      return 0;
    }
  }
  for (int i = 0; i < N; ++i)
    if (B[i]) {
      cout << "Yes\n";
      return 0;
    }

  while (true) {
    bool change = false;
    for (int i = 0; i < N; ++i) {
      if (A[i] > 1) {
        int d = A[i] / 2;
        A[i] -= 2 * d;
        A[(i + 1) % N] -= d;
        change = true;
      }
    }
    if (!change)
      break;
  }
  for (int i = 0; i < N; ++i)
    if (A[i]) {
      cout << "No\n";
      return 0;
    }
  cout << "Yes\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -