QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#418705 | #6748. Spin the Wheel | Texcavator# | WA | 7ms | 5248kb | C++20 | 1.3kb | 2024-05-23 15:15:28 | 2024-05-23 15:15:29 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
using i64 = long long;
typedef pair<int, int> PII;
typedef pair<int, char> PIC;
typedef pair<double, double> PDD;
typedef pair<int, PII> PIII;
typedef pair<int, pair<int, bool>> PIIB;
// const int N = 1e6 + 10;
const int maxn = 1e6 + 10;
const int mod = 998244353;
const int mod1 = 954169327;
const int mod2 = 906097321;
const int INF = 0x3f3f3f3f3f3f3f3f;
const int N = 1e5 + 10;
int a[N] , n , d[N];
void solve()
{
cin >> n;
for(int i = 0 ; i < n ; i ++){
cin >> a[i];
}
for(int i = 0 ; i < n ; i ++){
d[i] = (a[i] - a[(i - 1 + n) % n]);
}
int sum = 0 , pos = -1 , neg = 1;
for(int i = 0 ; i < n ; i ++){
sum += d[i];
if(d[i] > 0){
if(pos == -1)pos = d[i];
else if(pos != d[i]){
cout << -1 << '\n';
return;
}
}else if(d[i] < 0){
if(neg == 1)neg = d[i];
else if(neg != d[i]){
cout << -1 << '\n';
return;
}
}
}
if(sum != 0){
cout << -1 << '\n';
return;
}
int num = 0;
for(int i = 0 ; i < n ; i ++){
if(d[i] < 0)num ++;
}
if(d[n - 1] >= 0)num ++;
cout << num << '\n';
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int t = 1;
// cin >> t;
while (t--)
{
solve();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3688kb
input:
5 1 3 0 2 4
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 7ms
memory: 5232kb
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: -100
Wrong Answer
time: 5ms
memory: 5248kb
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:
50001
result:
wrong answer 1st numbers differ - expected: '50000', found: '50001'