結果
| 問題 | No.365 ジェンガソート | 
| コンテスト | |
| ユーザー |  dgd1724 | 
| 提出日時 | 2016-10-21 06:41:59 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 831 bytes | 
| コンパイル時間 | 1,725 ms | 
| コンパイル使用メモリ | 164,040 KB | 
| 実行使用メモリ | 13,640 KB | 
| 最終ジャッジ日時 | 2024-11-23 15:59:24 | 
| 合計ジャッジ時間 | 20,240 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 36 TLE * 5 | 
ソースコード
#include <bits/stdc++.h>
//const static double	de_PI	= 3.14159265358979323846;
//const static int	de_MOD	= 1000000007;
//const static int	de_MAX	= 999999999;
//const static int	de_MIN = -999999999;
int main(void) {
	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());
	int N = 0;
	std::cin >> N;
	std::list<int> A(N);
	for (auto itr = A.begin(); itr != A.end(); itr++) {
		std::cin >> *itr;
	}
	
	int ans = 0, max = 0;
	std::vector<int> temp;
	while (!A.empty()) {
		auto itr = std::max_element(A.begin(), A.end());
		if (max < *itr) {
			while (itr != --A.end()) {
				temp.push_back(A.back());
				A.pop_back();
				ans++;
			}
			A.pop_back();
			if (!temp.empty()) {
				max = *std::max_element(temp.begin(), temp.end());
			}
		}
		else {
			ans += A.size();
			break;
		}
	}
	
	std::cout << ans << std::endl;
}
            
            
            
        