結果
問題 |
No.365 ジェンガソート
|
ユーザー |
![]() |
提出日時 | 2016-04-29 23:20:02 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 393 bytes |
コンパイル時間 | 521 ms |
コンパイル使用メモリ | 60,192 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-04 18:55:22 |
合計ジャッジ時間 | 2,187 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 WA * 24 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:20:9: warning: ‘maxi’ may be used uninitialized in this function [-Wmaybe-uninitialized] 20 | if (maxi == N-1) { | ^~
ソースコード
#include <iostream> #include <vector> using namespace std; int main() { int N, maxi; vector<int> a; cin >> N; for (int i = 0, x, max = 0; i < N; ++i) { cin >> x; a.push_back(x); if (max < x) max = x, maxi = i; } int res = N - 1; if (maxi == N-1) { for (int i = N-1, x = N-1; i >= 0; --i) { if (a[i] == x - 1) --x, --res; } } cout << res << endl; return 0; }