結果
| 問題 | No.1394 Changing Problems |
| コンテスト | |
| ユーザー |
platinum
|
| 提出日時 | 2020-09-20 12:02:28 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 706 bytes |
| 記録 | |
| コンパイル時間 | 2,010 ms |
| コンパイル使用メモリ | 169,540 KB |
| 実行使用メモリ | 10,624 KB |
| 最終ジャッジ日時 | 2024-07-04 19:26:39 |
| 合計ジャッジ時間 | 6,704 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | TLE * 1 -- * 28 |
ソースコード
#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;
}
platinum