| Task: | Coins |
| Sender: | Karhukopla |
| Submission time: | 2018-05-26 11:51:54 +0300 |
| Language: | C++ |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.38 s | details |
| #2 | WRONG ANSWER | 0.34 s | details |
| #3 | ACCEPTED | 0.34 s | details |
| #4 | ACCEPTED | 0.32 s | details |
| #5 | ACCEPTED | 0.37 s | details |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:35:4: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
if (ans == '<') ans = '?';
^~Code
#include <bits/stdc++.h>
#define ll long long
#define lll __int128
#define pii pair<int, int>
#define M 1000000007
#define N (1<<18)
using namespace std;
int mx[2*N];
int mn[2*N];
int s[2*N];
void setv (int k, int n) {
k += N;
s[k] = mn[k] = mx[k] = n;
for (k /= 2; k >= 1; k /= 2) {
s[k] = s[2 * k] + s[2 * k + 1];
mn[k] = min(min(mn[2 * k], s[2 * k] + mn[2 * k + 1]), s[2 * k]);
mx[k] = max(max(mx[2 * k], s[2 * k] + mx[2 * k + 1]), s[2 * k]);
}
}
int main () {
int n;
cin>>n;
while (n --> 0) {
int c, s;
cin>>c>>s;
if (s == 2) s = -1;
setv(N - c, s);
char ans;
if (mn[1] < 0) ans = '<';
if (mx[1] > 0) {
if (ans == '<') ans = '?';
else ans = '>';
}
cout<<ans<<endl;
}
}Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| 200000 175878 1 146174 1 4939 2 181388 1 ... |
| correct output |
|---|
| > > > > > ... |
| user output |
|---|
| > > > > > ... |
Test 2
Verdict: WRONG ANSWER
| input |
|---|
| 200000 1 2 2 1 3 2 4 1 ... |
| correct output |
|---|
| < > < > < ... |
| user output |
|---|
| < ? < ? < ... |
Test 3
Verdict: ACCEPTED
| input |
|---|
| 200000 1 1 2 1 3 1 4 1 ... |
| correct output |
|---|
| > > > > > ... |
| user output |
|---|
| > > > > > ... |
Test 4
Verdict: ACCEPTED
| input |
|---|
| 200000 1 1 2 1 3 1 4 1 ... |
| correct output |
|---|
| > > > > > ... |
| user output |
|---|
| > > > > > ... |
Test 5
Verdict: ACCEPTED
| input |
|---|
| 200000 188909 2 58944 1 26824 1 143263 2 ... |
| correct output |
|---|
| < < ? < < ... |
| user output |
|---|
| < < ? < < ... |
