QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#750578#6748. Spin the WheelXfJbUhpyzgaW#WA 3ms4484kbC++11784b2024-11-15 15:03:192024-11-15 15:03:19

Judging History

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

  • [2024-11-15 15:03:19]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:4484kb
  • [2024-11-15 15:03:19]
  • 提交

answer

#include<bits/stdc++.h>
#define N 101000
#define ll long long
#define GC getchar()
using namespace std;
ll re(){
	ll s=0,b=1; char c=GC;
	while(c>'9'||c<'0'){if(c=='-')b=-b; c=GC;}
	while(c<='9'&&c>='0'){s=(s<<1)+(s<<3)+(c^48); c=GC;}
	return s*b;
}
int n,a[N],cf[N],s,ans,s1;
int main(){
	n=re();
	for(int i=1; i<=n; ++i)a[i]=re();
	cf[1]=a[1]-a[n];
	for(int i=2; i<=n; ++i)cf[i]=a[i]-a[i-1];
	for(int i=1; i<=n; ++i)s=max(s,cf[i]);
	ans+=s;
	for(int i=1; i<=n; ++i)cf[i]-=s;
	bool fl=0;
	for(int i=1; i<=n; ++i){
		if((-cf[i])%n!=0){cout<<"-1"; return 0;}
		s1+=(-cf[i])/n; 
		if(cf[i]!=0)
		 if(fl)ans++;
		  else fl=1;
	} 
	if(s1!=s)cout<<"-1";
	 else if(ans==s){
	 	if(fl==0&&a[1]!=0)cout<<"-1";
		 else cout<<ans+(a[1]!=0);
	 } else cout<<ans;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3568kb

input:

5
1 3 0 2 4

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: -100
Wrong Answer
time: 3ms
memory: 4484kb

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:

111109

result:

wrong answer 1st numbers differ - expected: '55555', found: '111109'