QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#643292 | #7747. Memory | Yu_mx | WA | 0ms | 3612kb | C++14 | 1.5kb | 2024-10-15 20:27:44 | 2024-10-15 20:27:45 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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: '-+++++++++'