結果
問題 | No.397 NO MORE KADOMATSU |
ユーザー |
![]() |
提出日時 | 2016-07-15 22:56:05 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 26 ms / 2,000 ms |
コード長 | 465 bytes |
コンパイル時間 | 112 ms |
コンパイル使用メモリ | 22,656 KB |
実行使用メモリ | 25,220 KB |
平均クエリ数 | 52.44 |
最終ジャッジ日時 | 2024-07-17 00:05:41 |
合計ジャッジ時間 | 1,699 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 6 | scanf("%d\n", &n); | ~~~~~^~~~~~~~~~~~ main.cpp:7:43: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | for(int i = 0; i < n; i++) { scanf("%d", &a[i]); } | ~~~~~^~~~~~~~~~~~~
ソースコード
#include <stdio.h> int n, a[100], b[100], c[100], d; int main() { scanf("%d\n", &n); for(int i = 0; i < n; i++) { scanf("%d", &a[i]); } for(int i = 0; i < n; i++) { int p = n - 1; for(int j = n - 1; j >= i; j--) { if(a[j] < a[p]) { p = j; } } if(p != i) { b[d] = i; c[d] = p; d++; } int temp = a[i]; a[i] = a[p]; a[p] = temp; } printf("%d\n", d); for(int i = 0; i < d; i++){ printf("%d %d\n", b[i], c[i]); } fflush(stdout); return 0; }