結果

問題 No.1008 Bench Craftsman
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2020-06-20 19:28:56
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,350 bytes
コンパイル時間 1,698 ms
コンパイル使用メモリ 145,796 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-16 17:43:25
合計ジャッジ時間 6,131 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 45 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 6 ms
4,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 83 ms
4,376 KB
testcase_16 WA -
testcase_17 AC 84 ms
4,376 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 38 ms
4,376 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 41 ms
4,380 KB
testcase_26 AC 32 ms
4,376 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.06.20 19:28:53
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int n,m;cin >> n >> m;
    vector<int> a(n);
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> b(n);
    for (int i = 0; i < m; i++) {
        int x,w;cin >> x >> w;
        x--;
        sum += w;
        b[0] += min(x,w);
        if (n > 1) b[1] -= min(x,w);
        if (x <= w && n > 1) {
            b[1] -= 1;
        }
        else if (x - w + 1 >= 0 && x - w + 1 < n) {
            b[x-w+1] -= 1;
        }
        if (x + 1 < n) b[x+1] += 2;
        if (x + w + 1 < n) b[x + w + 1] -= 1;
    }
    for (int i = 0; i < n - 1; i++) {
        b[i + 1] += b[i];
    }
    for (int i = 0; i < n - 1; i++) {
        b[i + 1] += b[i];
    }
    ll l = -1, r = 10000000001;
    while(r - l > 1) {
        ll mid = l + (r - l) / 2;
        bool ok = true;
        for (int i = 0; i < n; i++) {
            if (a[i] <= sum - mid * b[i]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            r = mid;
        }
        else {
            l = mid;
        }
    }
    if (r == 10000000001) {
        cout << -1 << endl;
    }
    else {
        cout << r << endl;
    }
    return 0;
}
0