Submission #1298290

#TimeUsernameProblemLanguageResultExecution timeMemory
1298290daotuankhoiRemittance (JOI19_remittance)C++20
15 / 100
1 ms580 KiB
#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define ll long long

#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif

template <class T> bool ckmax(T &a, T b) { return a < b ? (a = b, true) : false; }
template <class T> bool ckmin(T &a, T b) { return a > b ? (a = b, true) : false; }

const int MAXN = 1e6 + 5;
int a[MAXN], b[MAXN];
int main() {
    #define NAME "test"
    if (fopen(NAME".inp", "r")) {
        freopen(NAME".inp", "r", stdin);
        freopen(NAME".out", "w", stdout);
    }
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    int t = 50;
    while (t--) {
        bool ok = 1;
        for (int i = 0; i < n; i++) {
            if (a[i] > b[i]) {
                int val = min(a[i] / 2, (a[i] - b[i] + 1) / 2);
                a[i] -= val * 2;
                a[(i + 1) % n] += val;
            }
            ok &= a[i] == b[i];
        }
        if (ok) break;
    }
    for (int i = 0; i < n; i++) {
        if (a[i] != b[i]) return cout << "No\n", 0;
    }
    cout << "Yes\n";
    return 0;
}

Compilation message (stderr)

remittance.cpp: In function 'int main()':
remittance.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen(NAME".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
remittance.cpp:24:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         freopen(NAME".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...