Submission #787276

#TimeUsernameProblemLanguageResultExecution timeMemory
787276vjudge1Editor (BOI15_edi)C++14
35 / 100
3033 ms8364 KiB
#include <bits/stdc++.h> using namespace std; const int N = 3e5+7; pair <char, int> op[N]; pair <int, int> link[N]; int n; int main(){ cin >> n; op[0] = {'E', 0}; link[0] = {1, 0}; for (int i = 1; i <= n; i++){ int w; cin >> w; if (w < 0){ op[i] = {'U', -w}; } else { op[i] = {'E', w}; } } //cout << "\n"; for (int i = 1; i <= n; i++){ if (op[i].first == 'E'){ cout << op[i].second << "\n"; link[i] = {1, 0}; } else { int lv = op[i].second; for (int j = i-1; j >= 1; j--){ if (link[j].first == 1 && (op[j].first == 'E' || (op[j].first == 'U' && op[j].second < lv))){ link[i] = {1, j}; break; } } int ptr = link[i].second; while(ptr != 0){ //cout << ptr << ' '; link[ptr].first = 1 - link[ptr].first; //cout << link[ptr].first << "\n"; ptr = link[ptr].second; } //cout << "PTR\n"; for (int j = i; j >= 0; j--){ if (op[j].first == 'E' && link[j].first == 1){ cout << op[j].second << "\n"; break; } } } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...