結果
問題 |
No.406 鴨等間隔の法則
|
ユーザー |
|
提出日時 | 2018-03-19 21:43:20 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 19 ms / 2,000 ms |
コード長 | 524 bytes |
コンパイル時間 | 218 ms |
コンパイル使用メモリ | 36,940 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-07 12:21:36 |
合計ジャッジ時間 | 1,450 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:6:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 6 | scanf("%d",&N); | ~~~~~^~~~~~~~~ main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | scanf("%d",&x[i]); | ~~~~~^~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <algorithm> int main(){ //input int N; scanf("%d",&N); int x[100000]; for (int i = 0;i < N;i++){ scanf("%d",&x[i]); } //sort array x std::sort(x,x+N); //diffrence of x_i and x_i+1 int d = x[1]-x[0]; if (d == 0){ printf("NO\n"); return 0; } //search for (int i = 0;i <= N-2;i++){ if (x[i+1]-x[i] != d){ printf("NO\n"); return 0; } } printf("YES\n"); return 0; }