結果
| 問題 |
No.929 よくあるボールを移動するやつ
|
| ユーザー |
|
| 提出日時 | 2019-11-22 22:47:51 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 758 bytes |
| コンパイル時間 | 1,284 ms |
| コンパイル使用メモリ | 163,672 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-11 04:24:12 |
| 合計ジャッジ時間 | 2,071 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 9 WA * 3 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
queue<int> que;
int a[100010];
for(int i = 0;i < n;i++){
cin >> a[i];
}
int ans = 0;
int next = 0;
for(int i = 0;i < n;i++){
if(next > 0){
ans += next;
}
if(a[i] != 0){
while(a[i] > 1){
if(que.size() == 0){
break;
}
a[i]--;
ans += i - que.front();
que.pop();
}
next += a[i]-1;
}else{
if(next > 0){
next--;
}else{
que.push(i);
}
}
}
cout << ans << endl;
return 0;
}