結果

問題 No.1120 Strange Teacher
ユーザー ぷらぷら
提出日時 2020-07-22 21:59:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 862 bytes
コンパイル時間 3,844 ms
コンパイル使用メモリ 166,584 KB
実行使用メモリ 4,908 KB
最終ジャッジ日時 2023-09-04 19:57:16
合計ジャッジ時間 6,608 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 8 ms
4,380 KB
testcase_04 AC 60 ms
4,704 KB
testcase_05 AC 60 ms
4,608 KB
testcase_06 AC 59 ms
4,556 KB
testcase_07 AC 59 ms
4,900 KB
testcase_08 AC 60 ms
4,608 KB
testcase_09 AC 1 ms
4,384 KB
testcase_10 AC 60 ms
4,640 KB
testcase_11 AC 60 ms
4,612 KB
testcase_12 AC 60 ms
4,620 KB
testcase_13 AC 60 ms
4,568 KB
testcase_14 AC 60 ms
4,612 KB
testcase_15 AC 59 ms
4,620 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 66 ms
4,684 KB
testcase_20 AC 1 ms
4,384 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 WA -
testcase_23 AC 2 ms
4,384 KB
testcase_24 AC 51 ms
4,640 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 1 ms
4,384 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef 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 sum = 0;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        sum+=A[i];
    }
    int sum2 = 0;
    for(int i = 0; i < N; i++) {
        cin >> B[i];
        sum2+=B[i];
    }
    if(N == 2) {
        cout << abs(A[0]-B[0]) << endl;
        return 0;
    }
    if(abs(sum-sum2)%(N-2) == 0 && sum >= sum2) {
        int MA = (sum-sum2)/(N-2);
        int ans = 0;
        for(int i = 0; i < N; i++) {
            if(A[i]-MA < B[i]) {
                ans+=(B[i]-(A[i]-MA))/2;
            }
        }
        cout << ans << endl;
    }
    else {
        cout << -1 << endl;
    }
}
0