답안 #683343

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
683343 2023-01-18T08:20:15 Z tht2005 송금 (JOI19_remittance) C++17
0 / 100
2 ms 596 KB
#include <bits/stdc++.h>

using namespace std;

#define N 1000006
int a[N], b[N];
long long X[N];

int main() {
    freopen("remittance.inp", "r", stdin);
    freopen("remittance.out", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    long long S = 0;
    for(int i = 1; i <= n; ++i) {
        cin >> a[i] >> b[i];
        S += (long long)(b[i] - a[i]) << (i - 1);
    }
    if(S % (1 - (1LL << n)) != 0) {
        cout << "No";
        return 0;
    }
    X[n] = S / (1 - (1LL << n));
    if(X[n] < 0) {
        cout << "No";
        return 0;
    }
    X[0] = X[n];
    for(int i = 1; i < n; ++i) {
        long long val = X[i - 1] + a[i] - b[i];
        if(val < 0 || (val & 1)) {
            cout << "No";
            return 0;
        }
        X[i] = val >> 1;
    }
    cout << "Yes";
    return 0;
}

Compilation message

remittance.cpp: In function 'int main()':
remittance.cpp:10:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     freopen("remittance.inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
remittance.cpp:11:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     freopen("remittance.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -