結果
問題 |
No.406 鴨等間隔の法則
|
ユーザー |
|
提出日時 | 2025-03-19 09:31:02 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 23 ms / 2,000 ms |
コード長 | 496 bytes |
コンパイル時間 | 1,025 ms |
コンパイル使用メモリ | 76,572 KB |
実行使用メモリ | 7,324 KB |
最終ジャッジ日時 | 2025-03-19 09:31:06 |
合計ジャッジ時間 | 3,298 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:14:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 14 | scanf("%d",&n); | ~~~~~^~~~~~~~~ main.cpp:16:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 16 | rep(i,n)scanf("%d",&x[i]); | ~~~~~^~~~~~~~~~~~
ソースコード
#include<iostream> #include<vector> #include<algorithm> #include<cassert> #define rep(i,n) for(i=0;i<(int)(n);i++) using namespace std; typedef long long ll; typedef unsigned long long ull; int n; int main(){ int i,j; scanf("%d",&n); vector<int> x(n); rep(i,n)scanf("%d",&x[i]); sort(x.begin(),x.end()); rep(i,n-2){ if(x[i]+x[i+2]!=2*x[i+1]){ puts("NO"); return 0; } } printf("%s\n",x[0]==x[1]?"NO":"YES"); return 0; }