結果
| 問題 |
No.365 ジェンガソート
|
| コンテスト | |
| ユーザー |
kei
|
| 提出日時 | 2016-09-04 22:06:01 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 11 ms / 2,000 ms |
| コード長 | 388 bytes |
| コンパイル時間 | 556 ms |
| コンパイル使用メモリ | 59,124 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-15 20:16:47 |
| 合計ジャッジ時間 | 2,866 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 41 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:41: warning: ‘temp’ may be used uninitialized in this function [-Wmaybe-uninitialized]
13 | if (A[i] == temp) { temp--; count++; }
| ~~~~^~
main.cpp:12:18: warning: ‘at_N’ may be used uninitialized in this function [-Wmaybe-uninitialized]
12 | for (int i = at_N - 1; i >= 0; i--) {
| ^
ソースコード
#include <iostream>
#include <vector>
using namespace std;
int main() {
cin.tie(0); ios::sync_with_stdio(false);
int N,at_N,count = 1,temp; cin >> N;
vector<int> A(N);
for (int i = 0; i < N; i++) {
cin >> A[i];
if (A[i] == N) { at_N = i; temp = N - 1; }
}
for (int i = at_N - 1; i >= 0; i--) {
if (A[i] == temp) { temp--; count++; }
}
cout << N - count << endl;
return 0;
}
kei