結果
問題 |
No.929 よくあるボールを移動するやつ
|
ユーザー |
![]() |
提出日時 | 2020-03-14 11:34:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 487 bytes |
コンパイル時間 | 872 ms |
コンパイル使用メモリ | 79,164 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-23 18:40:35 |
合計ジャッジ時間 | 1,649 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 1 |
other | AC * 2 WA * 10 |
ソースコード
#include<iostream> #include<stdio.h> #include<algorithm> #include<vector> #include<string.h> #include<math.h> #include<iomanip> using namespace std; int main(){ long n; long count=0,j=0; cin >> n; int a[n],b[n],c[n]; for(int i=0;i<n;i++){ cin >> a[i]; if(a[i] >= 2){ b[j]=a[i]; c[j]=i; j++; } } for(int i=0;i<n;i++){ if(a[i] == 0){ a[i]=1; b[j] -= 1; count += abs(c[j]-i); if(b[j]==1){ j++; } } } cout << count << endl; return 0; }