QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#383957 | #6748. Spin the Wheel | qzhfx# | WA | 0ms | 3476kb | C++23 | 1.3kb | 2024-04-09 19:12:17 | 2024-04-09 19:12:18 |
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 + *st.begin()<< '\n';
}
}
signed main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int _;
_ = 1;
// cin >> _;
while (_--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3476kb
input:
5 1 3 0 2 4
output:
5
result:
wrong answer 1st numbers differ - expected: '3', found: '5'