結果
問題 | No.1120 Strange Teacher |
ユーザー |
![]() |
提出日時 | 2020-07-23 00:25:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,255 bytes |
コンパイル時間 | 1,302 ms |
コンパイル使用メモリ | 170,444 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-23 02:55:53 |
合計ジャッジ時間 | 3,393 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | AC * 4 WA * 23 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define int long longtypedef pair<int,int> P;int INF = 1e9+7;int mod = 1e9+7;int dx[4] = {1, 0, -1, 0};int dy[4] = {0, 1, 0, -1};signed main() {int N;cin >> N;vector<int>A(N);vector<int>B(N);int sumA = 0;for(int i = 0; i < N; i++) {cin >> A[i];sumA+=A[i];}int sumB = 0;for(int i = 0; i < N; i++) {cin >> B[i];sumB+=B[i];}if(sumA > sumB) {cout << 0 << endl;return 0;}if(N == 2) {//%0はできないためif(sumA != sumB) cout << 0 << endl;else cout << abs(A[0]-B[0]) << endl;return 0;}if((sumA-sumB)%(N-2) != 0) {cout << 0 << endl;return 0;}int K = (sumA-sumB)/(N-2);int cnt = K;//後何回操作できるかfor(int i = 0; i < N; i++) {if(A[i]-K < B[i]) {if((B[i]-(A[i]-K))/2 > cnt) {cout << 0 << endl;return 0;}cnt-=(B[i]-(A[i]-K))/2;}else {cout << 0 << endl;return 0;}}if(cnt != 0) {cout << 0 << endl;}else {cout << K << endl;}}