結果
| 問題 |
No.929 よくあるボールを移動するやつ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-11-22 22:46:38 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 730 bytes |
| コンパイル時間 | 1,655 ms |
| コンパイル使用メモリ | 163,776 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-11 04:23:19 |
| 合計ジャッジ時間 | 2,458 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 1 WA * 11 |
ソースコード
#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(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){
ans += next;
next--;
}else{
que.push(i);
}
}
}
cout << ans << endl;
return 0;
}