結果

問題 No.1120 Strange Teacher
ユーザー fastmathfastmath
提出日時 2020-07-22 21:28:16
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,340 bytes
コンパイル時間 6,748 ms
コンパイル使用メモリ 132,948 KB
実行使用メモリ 4,996 KB
最終ジャッジ日時 2023-09-04 15:13:35
合計ジャッジ時間 4,411 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 22 ms
4,552 KB
testcase_05 AC 22 ms
4,604 KB
testcase_06 AC 22 ms
4,584 KB
testcase_07 AC 22 ms
4,552 KB
testcase_08 AC 22 ms
4,620 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 22 ms
4,984 KB
testcase_11 AC 22 ms
4,988 KB
testcase_12 AC 22 ms
4,948 KB
testcase_13 AC 22 ms
4,948 KB
testcase_14 AC 22 ms
4,952 KB
testcase_15 AC 22 ms
4,992 KB
testcase_16 AC 21 ms
4,996 KB
testcase_17 AC 22 ms
4,984 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 24 ms
4,560 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 19 ms
4,556 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 WA -
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
#define debug(x) std::cout << #x << ": " << x << '\n';
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif

    int n;
    cin >> n;
    vector <int> a(n), b(n);

    int delt = 0;

    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        delt -= a[i];
    }   
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
        delt += b[i];
    }   

    if (n == 2) {
        if (delt != 0)
            cout << -1 << endl;
        else
            cout << abs(a[0] - b[0]) << endl;
    }   
    else {

        if (delt > 0) {
            cout << -1 << endl;
            exit(0);
        }   

        if ((-delt)%(n - 2)) {
            cout << -1 << endl;
            exit(0);
        }   

        int k = (-delt)/(n-2);
        for (int i = 0; i < n; ++i) {
            if (abs(a[i] - b[i]) > k) {
                cout << -1 << endl;
                exit(0);
            }   
        }
        cout << k << endl;
    }   

}
0