結果

問題 No.365 ジェンガソート
コンテスト
ユーザー rodea
提出日時 2017-12-22 17:53:53
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 341 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 571 ms
コンパイル使用メモリ 74,352 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-27 01:09:44
合計ジャッジ時間 5,729 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17 TLE * 1 -- * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:20:17: warning: 'c' may be used uninitialized [-Wmaybe-uninitialized]
   20 |                 if (b > c)
      |                 ^~
main.cpp:6:36: note: 'c' was declared here
    6 |         int n, i, j, a[100000], b, c;
      |                                    ^
main.cpp:20:17: warning: 'b' may be used uninitialized [-Wmaybe-uninitialized]
   20 |                 if (b > c)
      |                 ^~
main.cpp:6:33: note: 'b' was declared here
    6 |         int n, i, j, a[100000], b, c;
      |                                 ^

ソースコード

diff #
raw source code

#include<iostream>
using namespace std;

int main()
{
	int n, i, j, a[100000], b, c;

	cin >> n;

	for (i = 1; i <= n; i++) cin >> a[i];

	for (i = n; i >= 2; i--)
	{
		for (j = 1; j <= n; j++)
		{
			if (a[j] == i - 1) b = j;
			if (a[j] == i) c = j;
		}

		if (b > c)
		{
			cout << i - 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
}
0