結果

問題 No.1884 Sequence
ユーザー nyst
提出日時 2022-03-25 23:03:07
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 2,149 bytes
コンパイル時間 1,239 ms
コンパイル使用メモリ 112,144 KB
実行使用メモリ 34,652 KB
最終ジャッジ日時 2024-10-14 07:08:44
合計ジャッジ時間 7,830 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <fstream>
#include <cmath>
#include <stack>
#include <numeric>
#include <iomanip>
using namespace std;
int main(){
int n;cin>>n;
vector<long long> a(n);
map<long long,long long> mp;
for(int i=0;i<n;i++) {
cin >> a[i];
}
vector<long long> nozero;
sort(a.begin(),a.end(),greater<long long>());
long long maxv = a[0];
for(int i=0;i<n;i++) {
if(a[i]==0) {
continue;
}
nozero.push_back(a[i]);
mp[a[i]]++;
}
vector<long long> diff;
sort(nozero.begin(),nozero.end());
if(nozero.size()!=0 && nozero.size()!=1) {
for(int i=0;i<nozero.size()-1;i++) diff.push_back(nozero[i+1]-nozero[i]);
}else if(nozero.size()==1){
cout << "Yes" << endl;
return 0;
}else {
cout << "Yes" << endl;
return 0;
}
sort(diff.begin(),diff.end());
//
//for(int i=0;i<diff.size();i++) cout << diff[i] << " ";
//cout << endl;
//
long long mindiff = diff[0];
vector<long long> pb(n);
pb[0] = maxv;
int c = 0;
for(int i=1;i<n;i++) {
if(pb[i-1] - mindiff <0) {
c++;
}
pb[i] = pb[i-1] - mindiff;
}
int index = 0;
while(c){
if((pb[index]+pb[index+1])%2==1){
cout << "No"<< endl;
return 0;
}
if(n==n-c) {
cout << "No" << endl;
return 0;
}
pb[n-c]= (pb[index]+pb[index+1])/2;
index++;
c--;
}
sort(pb.begin(),pb.end());
map<long long,long long> mpb;
for(int i=0;i<n;i++) mpb[pb[i]]++;
//
//for(int i=n-1;0<=i;i--) cout << pb[i] << " ";
//cout << endl;
//
for(auto x:mp){
mpb[x.first]--;
if(mpb[x.first]<0){
cout << "No" << endl;
return 0;
}
}
int diff2 = pb[1]-pb[0];
for(int i=0;i<n-1;i++){
if(pb[i]+diff2 != pb[i+1]){
cout << "No" << endl;
return 0;
}
}
cout << "Yes" << endl;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0