結果

問題 No.365 ジェンガソート
ユーザー dgd1724dgd1724
提出日時 2016-10-21 06:41:59
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 831 bytes
コンパイル時間 1,588 ms
コンパイル使用メモリ 162,524 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-05-02 21:14:12
合計ジャッジ時間 6,279 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,624 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 199 ms
5,888 KB
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}

0