QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#385439 | #6748. Spin the Wheel | zsy623 | WA | 7ms | 5804kb | C++20 | 1.9kb | 2024-04-10 19:15:58 | 2024-04-10 19:15:58 |
Judging History
answer
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
#define int long long
#define PII pair<int,int>
#define PCI pair<char,int>
#define PSI pair<string,int>
using namespace std;
using LL = long long;
const int N = 1e7;
const int MOD = 998244353;
const int INF = 1e18;
void solve(){
int n; cin>>n;
vector<int>A(n+10);
for(int i=1;i<=n;i++){
cin>>A[i];
}
vector<int>T=A;
int ans=INF;
bool flag=true;
for(int i=1;i<=n;i++){
if(T[i]!=T[1]){
flag=false;
}
}
if(flag){
if(T[1]==0){
cout << 0 << "\n";
return ;
}else {
cout << n+1 << "\n";
return ;
}
}else {
int id=-1;
int minv=*min_element(T.begin()+1,T.begin()+n+1);
for(int i=1;i<=n;i++){
if(T[i]==minv){
id=i;
break ;
}
}
for(int i=1;i<=n;i++){
T[i]-=minv;
}
// if(id==-1){
// cout << -1 << "\n";
// return ;
// }
vector<int>t(1);
for(int i=id;i<=n;i++){
t.push_back(T[i]);
}
for(int i=1;i<id;i++){
t.push_back(T[i]);
}
int sub=t[2];
for(int i=3;i<=n;i++){
t[i]=((t[i]-sub*(i-1))%n+n)%n;
if(t[i]!=0){
cout << -1 << "\n";
return ;
}
}
if(id!=1){
sub++;
}
cout << sub << "\n";
}
}
signed main (){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int Task=1; //cin>>Task;
for(int T=1;T<=Task;T++){
//cout << "Test: " << T << "\n";
solve();
}
return 0;
}
/*
5
1 3 0 2 4
5
2 4 1 3 0
5
4 2 0 3 1
5
0 3 1 4 2
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3864kb
input:
5 1 3 0 2 4
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 3ms
memory: 5804kb
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: 6ms
memory: 5712kb
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: 7ms
memory: 5744kb
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:
400
result:
wrong answer 1st numbers differ - expected: '401', found: '400'