제출 #951493

#제출 시각아이디문제언어결과실행 시간메모리
951493Trisanu_DasEditor (BOI15_edi)C++17
63 / 100
264 ms90448 KiB
#include <bits/stdc++.h> using namespace std; int arr[400000]; int calculate(int x){ if(arr[x]>=0)return x; stack<int> q; q.push(arr[x]); for(int i = x - 1; i > 0; i--){ if(arr[i] > q.top()) q.pop(); else q.push(arr[i]); if(q.empty()) return calculate(i - 1); } return 0; } int main(){ int n; cin >> n; n++; arr[0] = 0; for(int i = 1; i < n; i++) cin >> arr[i]; if(n <= 6000){ for(int i = 1; i < n; i++) cout << arr[calculate(i)] << '\n'; return 0; } int mn = 0; for(int i = 1; i < n; i++) mn = min(mn, arr[i]); if(mn >= -1){ stack<int> q; q.push(0); for(int i = 1; i < n; i++){ if(arr[i] > 0) q.push(arr[i]); else q.pop(); cout << q.top() << '\n'; } }else{ for(int i = 1; i < n - 1; i++) cout << "1\n"; cout << arr[calculate(n - 1)] << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...