結果
| 問題 |
No.365 ジェンガソート
|
| コンテスト | |
| ユーザー |
HeyHey0111
|
| 提出日時 | 2016-04-29 23:27:49 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 760 bytes |
| コンパイル時間 | 622 ms |
| コンパイル使用メモリ | 69,860 KB |
| 実行使用メモリ | 13,640 KB |
| 最終ジャッジ日時 | 2024-10-04 19:04:47 |
| 合計ジャッジ時間 | 4,553 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 WA * 15 TLE * 5 -- * 7 |
ソースコード
#include<iostream>
#include<string>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;
int main(){
int n;
cin >> n;
vector<int> v(n);
vector<int> buf;
for(int i=0;i<n;i++)
cin >> v[i];
int cur =0;
int cnt=0;
int counter=0;
do{
cnt=0;
cur=0;
for(int i=0;i<v.size();i++){
if(cur<v[i]){
cur=v[i];
}else{
cnt++;
buf.push_back(v[i]);
v.erase(v.begin()+i);
i--;
}
}
sort(buf.begin(),buf.end());
buf.insert(buf.end(),v.begin(),v.end());
v.clear();
v.shrink_to_fit();
copy(buf.begin(),buf.end(),back_inserter(v));
buf.clear();
buf.shrink_to_fit();
counter+=cnt;
}while(cnt);
cout<<counter<<endl;
return 0;
}
HeyHey0111