結果

問題 No.365 ジェンガソート
コンテスト
ユーザー dgd1724
提出日時 2016-10-21 06:41:59
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 831 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,087 ms
コンパイル使用メモリ 179,724 KB
実行使用メモリ 12,800 KB
最終ジャッジ日時 2026-05-17 09:01:08
合計ジャッジ時間 5,357 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17 TLE * 1 -- * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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