結果

問題 No.1394 Changing Problems
ユーザー 👑 platinumplatinum
提出日時 2020-09-20 12:02:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 706 bytes
コンパイル時間 2,206 ms
コンパイル使用メモリ 168,012 KB
実行使用メモリ 7,548 KB
最終ジャッジ日時 2023-09-18 02:42:09
合計ジャッジ時間 7,700 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
using LL = long long;

int N;
vector<LL> A, B;
LL sum, max_A;

void solve(){
	LL dif=max_A-(N-2);
	if(dif<=0){
		cout << 0 << endl;
		return;
	}
	while(1){
		LL res=0;
		rep(i,N) B[i]=(N-2)-(A[i]-dif);
		rep(i,N) res+=B[i]/(N-1);
		if(res>=dif){
			cout << dif << endl;
			return;
		}
		dif++;
	}
}

int main(){
	cin >> N;
	A.resize(N), B.resize(N);
	rep(i,N) cin >> A[i];
	rep(i,N) sum+=A[i], max_A=max(max_A,A[i]);
	int Q;
	cin >> Q;
	rep(i,Q){
		int q;
		cin >> q;
		if(q==1){
			LL t, x;
			cin >> t >> x;
			max_A=max(max_A,x);
			t--;
			sum+=x-A[t];
			A[t]=x;
		}
		else{
			solve();
		}
	}

	return 0;
}
0