QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#383921 | #6748. Spin the Wheel | qzhfx# | WA | 0ms | 3588kb | C++23 | 1.4kb | 2024-04-09 18:51:45 | 2024-04-09 18:51:45 |
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>;
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 (auto x : a) {
if (x > 0) {
cnt ++;
}
// cout << x << " " ;
}
// cout << '\n';
if(s[1]==0)cnt --;
// cout << cnt << '\n';
cout << cnt + *st.begin()<< '\n';
}
}
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int _;
_ = 1;
// cin >> _;
while (_--) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3588kb
input:
5 1 3 0 2 4
output:
4
result:
wrong answer 1st numbers differ - expected: '3', found: '4'