QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#383959 | #6748. Spin the Wheel | qzhfx# | WA | 6ms | 4648kb | C++23 | 1.3kb | 2024-04-09 19:12:35 | 2024-04-09 19:12:36 |
Judging History
answer
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math,no-stack-protector")
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
using namespace std;
using ll = int64_t;
using LL = long long;
using ull = uint64_t;
using i128 = __int128_t;
using u128 = __uint128_t;
using pii = pair<ll, ll>;
#define int ll
const int mod = 998244353;
const int N = 1e7 + 7;
const int maxn = 1e5 + 100;
void solve() {
int n;
cin >> n;
vector<int>s(n + 1, 0);
set<int>st;
ll sum = 0;
int cnt = 0;
for (int i = 1; i <= n; i++) {
cin >> s[i];
sum += s[i];
}
if (sum == 0) {
cout << 0 << '\n';
return;
}
auto a = s;
for (int i = 2; i <= n; i++) {
st.insert(((s[i] - s[i - 1]) % n + n) % n);
}
st.insert(((s[1] - s[n]) % n + n) % n);
if (st.size() > 1 || *st.begin() == 0) {
cout << -1 << '\n';
} else {
for (int i = n; i >= 1; i--) {
a[i] -= a[i - 1];
a[i] += n;
a[i] %= n;
}
int cnt = 0;
for (int i = n; i >= 1; i--) {
a[i] -= a[i - 1];
a[i] += n;
a[i] %= n;
}
for (int i=1;i<=n;i++) {
cnt += a[i];
if(i==2)continue;
if(a[i] > 0)cnt ++;
}
cout << cnt<< '\n';
}
}
signed main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int _;
_ = 1;
// cin >> _;
while (_--) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3628kb
input:
5 1 3 0 2 4
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 6ms
memory: 4624kb
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: 5ms
memory: 4636kb
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: 0
Accepted
time: 6ms
memory: 4648kb
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:
401
result:
ok 1 number(s): "401"
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 4620kb
input:
100000 37631 70399 3167 35935 68703 1471 34239 67007 99775 32543 65311 98079 30847 63615 96383 29151 61919 94687 27455 60223 92991 25759 58527 91295 24063 56831 89599 22367 55135 87903 20671 53439 86207 18975 51743 84511 17279 50047 82815 15583 48351 81119 13887 46655 79423 12191 44959 77727 10495 4...
output:
132769
result:
wrong answer 1st numbers differ - expected: '32769', found: '132769'