結果

問題 No.851 テストケース
ユーザー michonz4
提出日時 2020-01-05 14:13:56
言語 C
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 637 bytes
コンパイル時間 232 ms
コンパイル使用メモリ 29,952 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-22 21:57:21
合計ジャッジ時間 1,043 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 16 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#define SWAP(type, a, b) {type tmp=a; a=b; b=tmp;}

int main() {
  int n;
  scanf("%d%*c", &n);

  char s[100];
  int arr[3], j=0;
  while (fgets(s, 100, stdin)!=NULL) {

    for (int i=0; s[i]!='\0'; i++) {
      if (s[i]==' ') {
        printf("assert\n");
        return 0;
      }
    }

    sscanf(s, "%d", &arr[j++]);
  }
   
  for (int i=0; i<n; i++) {
    for (int j=n-1; j>0; j--) {
      if (arr[j]<arr[j-1]) {
        SWAP(int, arr[j], arr[j-1]);
      }
    }
  }

  if (arr[0]==arr[1] || arr[1]==arr[2]) {
    printf("%d\n", arr[0]+arr[1]);
  } else {
    printf("%d\n", arr[0]+arr[2]);
  }

  return 0;
}
0