結果
問題 |
No.365 ジェンガソート
|
ユーザー |
![]() |
提出日時 | 2017-01-08 10:07:56 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 11 ms / 2,000 ms |
コード長 | 371 bytes |
コンパイル時間 | 360 ms |
コンパイル使用メモリ | 20,352 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-17 17:58:51 |
合計ジャッジ時間 | 2,312 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 41 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:7:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | scanf("%d", &n); | ^~~~~~~~~~~~~~~ main.c:11:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | scanf("%d", &a); | ^~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <stdbool.h> #define rep(i, n) for (i = 0; i < n; i++) int main() { int n; scanf("%d", &n); int i, a, ia, cnt = 1, t = -1; rep(i, n) { scanf("%d", &a); if (i == 0) ia = a; if (a == t + 1) { cnt++; t++; } else if (a > t + 1) { t = a; cnt = 1; } } int ans = n - cnt; if (ia == n - cnt) ans--; printf("%d\n", ans); return 0; }