# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1000600 | biximo | Building 4 (JOI20_building4) | C++17 | 1 ms | 6492 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define N 1000005
using namespace std;
int A[N], B[N], LIS[N], n, minv[N], maxv[N], bt[N];
string ans;
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n;
n <<= 1;
priority_queue<array<int,2>> miv, mav;
for(int i = 1; i <= n; i ++) {
cin >> A[i];
}
for(int i = 1; i <= n; i ++) {
cin >> B[i];
}
for(int i = 1; i <= n;) {
int j = i+1;
while(j <= n && B[j] >= B[j-1]) j ++;
for(int k = i; k < j; k ++) {
LIS[k] = j-1;
}
i = j;
}
for(int i = 1; i <= n; i ++) {
while(miv.size() && LIS[miv.top()[1]+1] != LIS[i-1]) miv.pop();
while(mav.size() && LIS[mav.top()[1]+1] != LIS[i-1]) mav.pop();
if(A[i-1] <= A[i]) {
minv[i] = minv[i-1]+1;
maxv[i] = maxv[i-1]+1;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |