結果
| 問題 |
No.365 ジェンガソート
|
| コンテスト | |
| ユーザー |
fiord
|
| 提出日時 | 2016-04-29 22:47:45 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 443 bytes |
| コンパイル時間 | 1,446 ms |
| コンパイル使用メモリ | 166,920 KB |
| 実行使用メモリ | 13,640 KB |
| 最終ジャッジ日時 | 2024-10-04 18:25:49 |
| 合計ジャッジ時間 | 4,902 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 WA * 6 TLE * 1 -- * 24 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
int n; cin>>n;
vector<int> a(n);
for(int i=0;i<n;i++) cin>>a[i];
int ans=0;
while(n){
vector<int> add;
for(int i=n-1;i>=0;i--){
if(a[i]!=n){
add.push_back(a[i]);
a.erase(a.end()-1);
}
else break;
}
sort(add.begin(),add.end());
ans+=add.size();
a.insert(a.begin(),add.begin(),add.end());
a.erase(a.end()-1);
n--;
}
cout<<ans<<endl;
return 0;
}
fiord