結果

問題 No.365 ジェンガソート
コンテスト
ユーザー feeling_burst
提出日時 2016-05-03 22:29:57
言語 C90(gcc12)
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
WA  
実行時間 -
コード長 377 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 246 ms
コンパイル使用メモリ 32,320 KB
最終ジャッジ日時 2026-02-23 21:14:16
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11 WA * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:10:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |   scanf("%d", &N);
      |   ^~~~~~~~~~~~~~~
main.c:12:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |     scanf("%d", &a[i]);
      |     ^~~~~~~~~~~~~~~~~~

ソースコード

diff #
raw source code

#include <stdio.h>
#include <string.h>
#include <math.h>
int main(void) {
  int N;
  int i;
  int a[1000000];
  int t;
  int cnt = 0; 
  scanf("%d", &N);
  for (i = 0; i < N; i++) {
    scanf("%d", &a[i]);
  }
  for (i = N-1; i > 0; i--) {
    if (a[i-1] > a[i]) {
      t = a[i-1];
      a[i-1] = a[i];
      a[i] = t;
      cnt++;
    }
  }
  printf("%d",cnt);
  return 0;
}
0