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