結果
問題 |
No.406 鴨等間隔の法則
|
ユーザー |
![]() |
提出日時 | 2017-12-12 07:32:52 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 46 ms / 2,000 ms |
コード長 | 777 bytes |
コンパイル時間 | 677 ms |
コンパイル使用メモリ | 89,560 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-07 12:17:25 |
合計ジャッジ時間 | 2,525 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include <iostream> #include <stdio.h> #include <algorithm> #include <vector> #include <cmath> #include <string> #include <sstream> #include<sstream> #include <queue> #include <limits> #include <cstdlib> #include <deque> #include <map> #include <set> #include <iomanip> using namespace std; int main() { int n=0; vector<long> distance; cin>>n; long tmp=0; for(int i=0; i<n; i++){ cin>>tmp; distance.push_back(tmp); } sort(distance.begin(),distance.end()); long same_disatance = distance[1]-distance[0]; bool judge =true; for(int i=1; i<distance.size()-1; i++){ if((distance[i+1] -distance[i]) != same_disatance || distance[i+1] ==distance[i]){ cout<<"NO"<<endl; judge = false; break; } } if(judge){ cout<<"YES"<<endl; } return 0; }