QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#396843 | #6748. Spin the Wheel | fangz | WA | 0ms | 6868kb | C++14 | 1.2kb | 2024-04-23 11:26:16 | 2024-04-23 11:26:16 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define x first
#define y second
#define endl '\n'
#define int long long
const LL maxn = 4e05+7;
const LL N = 5e05+10;
const LL mod = 1e09+7;
const int inf = 0x3f3f3f3f;
const LL llinf = 5e18;
typedef pair<int,int>pl;
priority_queue<LL , vector<LL>, greater<LL> >mi;//小根堆
priority_queue<LL> ma;//大根堆
LL gcd(LL a, LL b){
return b > 0 ? gcd(b , a % b) : a;
}
LL lcm(LL a , LL b){
return a / gcd(a , b) * b;
}
int n , m;
vector<int>a(N , 0);
void init(int n){
for(int i = 0 ; i <= n ; i ++){
a[i] = 0;
}
}
void solve()
{
cin >> n;
for(int i = 0 ; i < n ; i ++){
cin >> a[i];
}
a[n] = a[0];
for(int i = 1 ; i <= n ; i ++){
if(a[i] < a[i - 1]){
int k = (a[i - 1] - a[i] - 1 + n) / n;
a[i] += k * n;
//cout << a[i] << endl;
}
if(a[i] - a[i - 1] != a[1] - a[0]){
cout << -1;
return;
}
}
int ans = a[1] - a[0];
if(a[0] == 0)
ans++;
cout <<ans;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cout.precision(10);
int t=1;
//cin>>t;
while(t--)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 6868kb
input:
5 1 3 0 2 4
output:
2
result:
wrong answer 1st numbers differ - expected: '3', found: '2'