QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#383957#6748. Spin the Wheelqzhfx#WA 0ms3476kbC++231.3kb2024-04-09 19:12:172024-04-09 19:12:18

Judging History

你现在查看的是最新测评结果

  • [2024-04-09 19:12:18]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3476kb
  • [2024-04-09 19:12:17]
  • 提交

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'