結果
問題 |
No.406 鴨等間隔の法則
|
ユーザー |
![]() |
提出日時 | 2016-09-03 17:52:03 |
言語 | C90 (gcc 12.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 465 bytes |
コンパイル時間 | 302 ms |
コンパイル使用メモリ | 21,248 KB |
実行使用メモリ | 10,496 KB |
最終ジャッジ日時 | 2024-11-07 05:36:48 |
合計ジャッジ時間 | 9,889 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | TLE * 2 -- * 27 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:6:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 6 | scanf("%d",&n); | ^~~~~~~~~~~~~~ main.c:10:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | scanf("%d",&data[i]); | ^~~~~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h> void swap(int *a,int *b); int main(void) { int n; scanf("%d",&n); int data[n]; int i,j; for(i=0;i<n;i++){ scanf("%d",&data[i]); } for(i=n-1;i>=0;i--){ for(j=0;j<i;j++){ if(data[j]>data[j+1])swap(&data[j],&data[j+1]); } } for(i=0;i<n-2;i++){ if(data[i]-data[i+1]!=data[i+1]-data[i+2]){ printf("NO\n"); return 0; } } printf("YES\n"); return 0; } void swap(int *a,int *b){ int temp; temp=*a; *a=*b; *b=temp; }