제출 #296452

#제출 시각아이디문제언어결과실행 시간메모리
296452BeanZ송금 (JOI19_remittance)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' const int N = 1e6 + 5; ll a[N], b[N]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); if (fopen("balance.in", "r")){ freopen("balance.in", "r", stdin); freopen("balance.out", "w", stdout); } ll n; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i] >> b[i]; while (true){ bool flag = false; for (int i = 1; i < n; i++){ if (a[i] > b[i] && a[i] > 1){ ll rem = a[i] - b[i] + 1; ll pass = rem / 2; if ((pass * 2) > a[i]) pass--; flag = true; a[i + 1] += pass; a[i] -= pass * 2; } } if (a[n] > b[n] && a[n] > 1){ ll rem = a[n] - b[n] + 1; ll pass = rem / 2; if ((pass * 2) > a[i]) pass--; flag = true; a[1] += pass; a[n] -= pass * 2; } if (!flag) break; } for (int i = 1; i <= n; i++){ if (a[i] != b[i]) return cout << "No", 0; } cout << "Yes"; } /* */

컴파일 시 표준 에러 (stderr) 메시지

remittance.cpp: In function 'int main()':
remittance.cpp:34:44: error: 'i' was not declared in this scope
   34 |                         if ((pass * 2) > a[i]) pass--;
      |                                            ^
remittance.cpp:13:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   13 |                 freopen("balance.in", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
remittance.cpp:14:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   14 |                 freopen("balance.out", "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~