QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#399246#6748. Spin the WheelblhxzjrWA 0ms3520kbC++20893b2024-04-26 08:21:012024-04-26 08:21:02

Judging History

你现在查看的是最新测评结果

  • [2024-04-26 08:21:02]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3520kb
  • [2024-04-26 08:21:01]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define int long long
int n,m,k,_;

const int N=1e5+7;

int a[N];

void main2(){
    cin>>n;
    rep(i,1,n){
        cin>>a[i];
    }    
    vector<int>d(n+1,0);
    vector<int>d1(n+1,1);
    d1[1]=1-n;
    int sum=0;
    int mx=-1;
    int cnt=1;
    rep(i,1,n){
        if(i==1)d[i]=a[i]-a[n];
        else d[i]=a[i]-a[i-1];
        sum+=d[i];
        mx=max(mx,abs(d[i]));
    }
    rep(i,1,n){
        if(mx!=d[i])
        if(mx+abs(d[i])!=n) cnt=0;
    }
    if(sum!=0){
        cout<<"-1"; return;
    }
    if(cnt)cout<<mx+(a[1]==0);
    else cout<<n-mx+(a[1]==0);
}

signed main(){
    ios::sync_with_stdio(false); cin.tie(0);
    _=1; 
    //cin>>_;
    while(_--){
        main2(); 
        if(_) cout<<endl;
    }
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3520kb

input:

5
1 3 0 2 4

output:

2

result:

wrong answer 1st numbers differ - expected: '3', found: '2'