結果

問題 No.1394 Changing Problems
コンテスト
ユーザー platinum
提出日時 2020-09-20 12:02:28
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 706 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,946 ms
コンパイル使用メモリ 183,488 KB
実行使用メモリ 13,056 KB
最終ジャッジ日時 2026-03-26 02:38:54
合計ジャッジ時間 88,815 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other AC * 1 WA * 5 RE * 2 TLE * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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