제출 #148100

#제출 시각아이디문제언어결과실행 시간메모리
148100WhipppedCreamEditor (BOI15_edi)C++17
100 / 100
644 ms195312 KiB
#include <bits/stdc++.h> //#ifdef atom #else #endif using namespace std; typedef long long ll; typedef pair<int, int> ii; #define X first #define Y second #define vi vector<int> #define vii vector< ii > #define pb push_back int n; struct node { int v; node *left, *right; node(int _v, node *a, node *b) { v = _v; left = a; right = b; } node *insert(int x, int dx, int L = 0, int R = n) { if(L<= x && x<= R) { if(L == R) return new node(dx, NULL, NULL); int M = (L+R)/2; node *ret = new node(0, left->insert(x, dx, L, M), right->insert(x, dx, M+1, R)); ret->v = max(ret->left->v, ret->right->v); //printf("L R is %d\n", ret->v); return ret; } return this; } int ask(int i, int j, int L = 0, int R = n) { if(i> R || j< L) return 0; if(i<= L && R<= j) return v; int M = (L+R)/2; int x = left->ask(i, j, L, M); int y = right->ask(i, j, M+1, R); return max(x, y); } }; const int maxn = 3e5+5; node *root[maxn]; int num[maxn]; node *zero; int main() { //#ifndef atom freopen(".in", "r", stdin); freopen(".out", "w", stdout); #endif cin >> n; zero = new node(0, NULL, NULL); zero->left = zero->right = zero; root[0] = zero; for(int i = 1; i<= n; i++) { int x; scanf("%d", &x); if(x> 0) { root[i] = root[i-1]->insert(0, i); num[i] = x; } else { x = -x; int det = root[i-1]->ask(0, x-1); det--; //printf("from (%d)\n", det); root[i] = root[det]->insert(x, i); //printf("max is %d\n", root[i]->ask(0, 1)); } printf("%d\n", num[root[i]->ask(0, 0)]); //cout << num[root[i]->ask(0, 0)] << endl; } }

컴파일 시 표준 에러 (stderr) 메시지

edi.cpp: In function 'int main()':
edi.cpp:56:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int x; scanf("%d", &x);
                ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...