結果
問題 | No.406 鴨等間隔の法則 |
ユーザー |
![]() |
提出日時 | 2016-12-10 18:01:22 |
言語 | C90 (gcc 11.4.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,007 bytes |
コンパイル時間 | 636 ms |
コンパイル使用メモリ | 22,272 KB |
実行使用メモリ | 10,496 KB |
最終ジャッジ日時 | 2024-11-07 06:52:42 |
合計ジャッジ時間 | 5,200 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 10 ms
10,496 KB |
testcase_01 | AC | 1 ms
5,248 KB |
testcase_02 | AC | 1 ms
5,248 KB |
testcase_03 | AC | 1 ms
5,248 KB |
testcase_04 | AC | 22 ms
5,248 KB |
testcase_05 | AC | 9 ms
5,248 KB |
testcase_06 | AC | 8 ms
5,248 KB |
testcase_07 | AC | 9 ms
5,248 KB |
testcase_08 | AC | 21 ms
5,248 KB |
testcase_09 | AC | 24 ms
5,248 KB |
testcase_10 | AC | 10 ms
5,248 KB |
testcase_11 | AC | 18 ms
5,248 KB |
testcase_12 | AC | 12 ms
5,248 KB |
testcase_13 | AC | 11 ms
5,248 KB |
testcase_14 | AC | 20 ms
5,248 KB |
testcase_15 | AC | 18 ms
5,248 KB |
testcase_16 | AC | 3 ms
5,248 KB |
testcase_17 | AC | 2 ms
5,248 KB |
testcase_18 | AC | 2 ms
5,248 KB |
testcase_19 | AC | 2 ms
5,248 KB |
testcase_20 | AC | 3 ms
5,248 KB |
testcase_21 | AC | 3 ms
5,248 KB |
testcase_22 | AC | 5 ms
5,248 KB |
testcase_23 | AC | 13 ms
5,248 KB |
testcase_24 | AC | 18 ms
5,248 KB |
testcase_25 | AC | 24 ms
5,248 KB |
testcase_26 | AC | 25 ms
5,248 KB |
testcase_27 | TLE | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
コンパイルメッセージ
main.c: In function ‘run’: main.c:49:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 49 | scanf("%d",&n); | ^~~~~~~~~~~~~~ main.c:55:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 55 | scanf("%d",x+i); | ^~~~~~~~~~~~~~~
ソースコード
#include<stdio.h> #include<stdlib.h> #include<time.h> void sort_q(int *a,int n){ if(n<=8) return; int p=rand()%n; int pivot=a[p]; a[p]=a[0]; int l=1; int r=n-1; while(l<=r){ if(a[l]<pivot){ a[l-1]=a[l]; l++; } else { int swap=a[r]; a[r]=a[l]; a[l]=swap; r--; } } a[r]=pivot; sort_q(a,r); sort_q(a+r+1,n-r-1); } void sort(int *a,int n){ sort_q(a,n); int i; for(i=1;i<n;i++){ int p=a[i]; int j=i-1; while(j>=0 && a[j]>p){ a[j+1]=a[j]; j--; } a[j+1]=p; } return; } void run(void){ int n; scanf("%d",&n); int *x; x=(int *)malloc(sizeof(int)*n); int i; for(i=0;i<n;i++){ scanf("%d",x+i); } srand((unsigned)time(NULL)); sort(x,n); int d=x[1]-x[0]; if(d==0){ printf("NO\n"); return; } i=2; while(i<n && x[i]-x[i-1]==d){ i++; } if(i==n){ printf("YES\n"); } else { printf("NO\n"); } return; } int main(void){ run(); return 0; }