QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#371657 | #6748. Spin the Wheel | swimseal | WA | 17ms | 5264kb | C++14 | 983b | 2024-03-30 14:48:00 | 2024-03-30 14:48:02 |
Judging History
answer
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
const int N = 2e5 + 10;
const double eps = 1e-9;
int n;
int a[N];
void solve(){
cin >> n;
int maxv = 0, minn = 1e8;
for (int i = 0; i < n ; i ++){
cin >> a[i],a[i + n] = a[i];
maxv = max(a[i], maxv);
minn = min(a[i], minn);
}
if(maxv == minn){
if(minn == 0){
cout << 0 << endl;
}
else if(minn == n - 1){
cout << n << endl;
}
else puts("-1");
return;
}
int id = 0;
while(a[id] != 0) id ++;
int cnt = a[id + 1];
//6cout << a[id + 1] << endl;
for (int i = id,t = 0; i < id + n; i ++,t ++){
if(a[i] != (1ll* t * cnt) % n){
cout << -1;
return;
}
}
if(id != 0) cnt ++;
cout << cnt << endl;
}
signed main(){
int t = 1;// cin >>t;
while(t --) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3480kb
input:
5 1 3 0 2 4
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 17ms
memory: 5264kb
input:
100000 0 55555 11110 66665 22220 77775 33330 88885 44440 99995 55550 11105 66660 22215 77770 33325 88880 44435 99990 55545 11100 66655 22210 77765 33320 88875 44430 99985 55540 11095 66650 22205 77760 33315 88870 44425 99980 55535 11090 66645 22200 77755 33310 88865 44420 99975 55530 11085 66640 221...
output:
55555
result:
ok 1 number(s): "55555"
Test #3:
score: 0
Accepted
time: 13ms
memory: 5240kb
input:
100000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 50000 0 500...
output:
50000
result:
ok 1 number(s): "50000"
Test #4:
score: -100
Wrong Answer
time: 17ms
memory: 5084kb
input:
100000 1 401 801 1201 1601 2001 2401 2801 3201 3601 4001 4401 4801 5201 5601 6001 6401 6801 7201 7601 8001 8401 8801 9201 9601 10001 10401 10801 11201 11601 12001 12401 12801 13201 13601 14001 14401 14801 15201 15601 16001 16401 16801 17201 17601 18001 18401 18801 19201 19601 20001 20401 20801 21201...
output:
-1
result:
wrong answer 1st numbers differ - expected: '401', found: '-1'