QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#595330 | #7747. Memory | Sunlight9# | WA | 1ms | 5700kb | C++20 | 831b | 2024-09-28 13:27:38 | 2024-09-28 13:27:39 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAXN=1e6+7;
const double eps=1e-9;
int n;
double a[MAXN];
char ans[MAXN];
int main() {
cin.tie(nullptr) -> sync_with_stdio(false);
cin>>n;
bool flag=0;
double sum=0LL;
for(int i=1;i<=n;i++)
{
cin>>a[i];
sum*=0.5;
if(!flag)
{
ll sumk=sum;
double sss=sum-sumk;
if(abs(sss)>eps) flag=1;
}
sum+=a[i];
if(!flag)
{
if(abs(sum)<=eps)
{
ans[i]='0';
continue;
}
}
if(sum<-eps) ans[i]='-';
else ans[i]='+';
}
for(int i=1;i<=n;i++) cout<<ans[i];
return 0;
}
/*
10
2 -1 4 -7 4 -8 3 -6 4 -7
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5700kb
input:
10 2 -1 4 -7 4 -8 3 -6 4 -7
output:
+0+-+---+-
result:
ok single line: '+0+-+---+-'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
10 -1 36 18 18 18 18 18 18 18 -18
output:
-++++++++-
result:
ok single line: '-++++++++-'
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3804kb
input:
1000 -1 193552 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 96776 967...
output:
-+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++...
result:
wrong answer 1st lines differ - expected: '-+++++++++++++++++++++++++++++...++++++++++++++++++++++++++++++-', found: '-+++++++++++++++++++++++++++++...+++++++++++++++++++++++++++++++'