結果

問題 No.365 ジェンガソート
ユーザー FF256grhy
提出日時 2016-04-30 00:41:28
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 257 bytes
コンパイル時間 369 ms
コンパイル使用メモリ 22,784 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-12 01:51:27
合計ジャッジ時間 1,832 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 41
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:5:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |         scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~
main.cpp:6:43: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |         for(int i = 0; i < n; i++) { scanf("%d", &a[i]); }
      |                                      ~~~~~^~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

int main() {
	int n, a[100000];
	scanf("%d", &n);
	for(int i = 0; i < n; i++) { scanf("%d", &a[i]); }
	
	int b = n, c = 0;
	for(int i = n - 1; 0 <= i; i--) {
		if(a[i] == b) { b--; } else { c++; }
	}
	
	printf("%d\n", c);
	
	return 0;
}
0