結果

問題 No.1008 Bench Craftsman
ユーザー furafura
提出日時 2020-03-06 23:08:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,157 bytes
コンパイル時間 2,121 ms
コンパイル使用メモリ 192,768 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-22 10:24:04
合計ジャッジ時間 3,412 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
5,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
5,376 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 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
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;
using lint=long long;

int main(){
puts("0"); return 0;
	int n,m; scanf("%d%d",&n,&m);
	vector<lint> a(n);
	rep(i,n) scanf("%lld",&a[i]);
	vector<int> x(m);
	vector<lint> w(m);
	rep(j,m) scanf("%d%lld",&x[j],&w[j]), x[j]--;

	vector<lint> wsum(n);
	rep(j,m) wsum[x[j]]+=w[j];
	rep(i,n) if(wsum[i]>=a[i]) return puts("-1"),0;

	if(accumulate(w.begin(),w.end(),0LL)<*min_element(a.begin(),a.end())) return puts("0"),0;

	const int OFFSET=2e5;
	vector<lint> sum(n+2*OFFSET);

	int lo=0,hi=1e5;
	while(hi-lo>1){
		int mi=(lo+hi)/2;

		int c=mi;
		fill(sum.begin(),sum.end(),0LL);
		rep(j,m){
			// left
			sum[x[j]-w[j]/c+OFFSET]+=c;
			sum[x[j]+OFFSET]-=c;
			sum[x[j]-w[j]/c+OFFSET-1]+=w[j]%c;
			sum[x[j]-w[j]/c+OFFSET]-=w[j]%c;
			// right
			sum[x[j]+OFFSET]-=c;
			sum[x[j]+w[j]/c+OFFSET]+=c;
			sum[x[j]+w[j]/c+OFFSET]-=w[j]%c;
			sum[x[j]+w[j]/c+OFFSET+1]+=w[j]%c;
		}
		rep(_,2) rep(i,(int)sum.size()-1) sum[i+1]+=sum[i];

		bool ok=true;
		rep(i,n) if(sum[i+OFFSET]>=a[i]) { ok=false; break; }
		if(ok) hi=mi;
		else   lo=mi;
	}
	printf("%d\n",hi);

	return 0;
}
0