結果
問題 |
No.406 鴨等間隔の法則
|
ユーザー |
![]() |
提出日時 | 2017-02-09 12:35:33 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 47 ms / 2,000 ms |
コード長 | 408 bytes |
コンパイル時間 | 1,908 ms |
コンパイル使用メモリ | 160,204 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-07 11:58:11 |
合計ジャッジ時間 | 3,347 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include <bits/stdc++.h> #include <iostream> #include <string> #include <stdlib.h> using namespace std; int main() { int n; cin>>n; int a[n]; for (int i = 0; i < n; ++i) { cin>>a[i]; } sort(a,a+n); int width=a[1]-a[0]; if(width==0){cout<<"NO"<<endl;return 0;} for (int i = 1; i < n-1; ++i) { if(a[i+1]-a[i]!=width||a[i+1]-a[i]==0){ cout<<"NO"<<endl; return 0; } } cout<<"YES"<<endl; }