結果

問題 No.1008 Bench Craftsman
ユーザー kappybarkappybar
提出日時 2020-04-03 20:03:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,268 bytes
コンパイル時間 1,439 ms
コンパイル使用メモリ 166,708 KB
実行使用メモリ 5,724 KB
最終ジャッジ日時 2023-09-16 00:06:21
合計ジャッジ時間 5,257 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll INF = 1e18;
const int MOD = 1000000007;

int main(){
        int n,m;
        cin >> n >> m;
        vector<ll> a(n);
        vector<ll> weight(n);
        vector<ll> cen(n);
        rep(i,n) cin >> a[i];
        ll sum_weight = 0;
        rep(i,m){
                ll x,w;
                cin >> x >> w;
                --x;
                cen[x] ++;
                weight[0] += abs(x);
                sum_weight += w;
        }

        ll cnt = cen[0];
        for(int i=1;i<n;i++){
                weight[i] = weight[i-1] + 2*cnt - m;
                cnt += cen[i];
        }

        bool ok = true;
        ll ans = 0;
        rep(i,n){
                if(sum_weight - a[i] < 0) continue;
                if(weight[i] == 0){
                        if(sum_weight - a[i] <= 0) continue;
                        else{
                                ok = false;
                                break;
                        }
                }
                ans = max(ans,(sum_weight-a[i]+weight[i]-1)/weight[i]);
        }

        if(ok) cout << ans << endl;
        else cout << -1 << endl;
        return 0;
}




0