QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#643292#7747. MemoryYu_mxWA 0ms3612kbC++141.5kb2024-10-15 20:27:442024-10-15 20:27:45

Judging History

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

  • [2024-10-15 20:27:45]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3612kb
  • [2024-10-15 20:27:44]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define endl '\n'

const int N = 2e5+5;

ll a[N];

void solve(){
	ll n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	ll ans = 0;
	ll sum = 0, ys = 0;
	for(int i=1;i<=n;i++){
		if(ans==-1){
			if(sum%2==-1) ys = 1;
			if(a[i]<=0){
				sum = sum/2+a[i];
				ans = -1;
			} 
			else{
				if(ys){
					if(a[i]+sum/2>=1){
						sum = a[i]+sum/2;
						ans = 1;
					}
					else{
						sum = a[i]+sum/2;
						ans = -1;
					}
				}
				else{
					if(a[i]+sum/2>0) ans = 1;
					else if(a[i]+sum/2==0) ans = 0;
					else ans = -1;
					sum = sum/2+a[i];
				}
			}
		}
		else if(ans == 0){
			if(a[i]>0){
				sum = sum/2+a[i];
				ans = 1;
			}
			else if(a[i]==0){
				sum = sum/2+a[i];
				ans = 0;
			}
			else{
				sum = sum/2+a[i];
				ans = -1;
			}
		}
		else if(ans == 1){
			if(sum%2==1) ys = 1;
			if(a[i]>=0){
				sum = sum/2+a[i];
				ans = 1;
			} 
			else{
				if(ys){
					if(a[i]+sum/2<=-1){
						sum = a[i]+sum/2;
						ans = -1;
					}
					else{
						sum = a[i]+sum/2;
						ans = 1;
					}
				}
				else{
					if(a[i]+sum/2>0) ans = 1;
					else if(a[i]+sum/2==0) ans = 0;
					else ans = -1;
					sum = sum/2+a[i];
				}
			}
		}
		if(ans == 1) cout<<'+';
		else if(ans == -1) cout<<'-';
		else cout<<0;
		//cout<<sum<<' '<<ys<<endl;
	}
}

int main(){
	ios;
	//ll T;cin>>T;while(T--)
	solve();
	return 0;
} 

详细

Test #1:

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

input:

10
2 -1 4 -7 4 -8 3 -6 4 -7

output:

+0+-+---+-

result:

ok single line: '+0+-+---+-'

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3536kb

input:

10
-1 36 18 18 18 18 18 18 18 -18

output:

-+++++++++

result:

wrong answer 1st lines differ - expected: '-++++++++-', found: '-+++++++++'