QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#757990#7747. Memorya2965983970WA 0ms3868kbC++141.2kb2024-11-17 15:01:142024-11-17 15:01:15

Judging History

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

  • [2024-11-17 15:01:15]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3868kb
  • [2024-11-17 15:01:14]
  • 提交

answer

#include<bits/stdc++.h>
#define ull unsigned long long
#define lch(x) t[x].s[0]
#define rch(x) t[x].s[1]
#define INF 0x3f3f3f3f
#define ll long long
#define lll __int128
#define re register
#define inl inline
#define N 1000050
#define rx x<<1|1
#define lx x<<1
#define double long double
using namespace std;

inline int read(){
    int w = 1 ,s = 0;
    char ch = getchar();
    while(!isdigit(ch)){
        if(ch=='-') w = -1;
        ch = getchar();
    }
    while(isdigit(ch)){
        s = (s<<3)+(s<<1)+ch-'0';
        ch = getchar();
    }
    return w*s;
}

const double eps = 1e-9;

int sgn(double x)
{
    if(fabsl(x) < eps) return 0;
    else return x < 0 ? -1 : 1;
}

int dcmp(double x, double y)
{
    if(fabsl(x - y) < eps) return 0;
    else return x < y ? -1 : 1;
}
void solve(){
    int n;
    cin >> n;
    vector<int> a(n + 1);
    for(int i = 1; i <= n; i ++) cin >> a[i];
    double sum = 0.0;
    for(int i = 1; i <= n; i ++)
    {
        sum = 0.5 * sum + 1.0 * a[i];
        if(sgn(sum) == 0) cout << 0 ;
        else if(sgn(sum) < 0) cout << '-';
        else cout << '+';
    }
    cout << endl;
}

int main(){
    ios::sync_with_stdio(false);


        solve() ;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3556kb

input:

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

output:

-++++++++-

result:

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

Test #3:

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

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: '-+++++++++++++++++++++++++++++...++++++++++++++++++++++++++++++0'