# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
999699 | Unforgettablepl | Building 4 (JOI20_building4) | C++17 | 2 ms | 856 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>
using namespace std;
#define int long long
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<int> A(2*n+2);
vector<int> B(2*n+2);
A[2*n+1]=B[2*n+1]=1e9;
vector<bool> chosen(2*n+1);
vector<int> val(2*n+2);val[2*n+1]=1e9;
for(int i=1;i<=2*n;i++)cin>>A[i];
for(int i=1;i<=2*n;i++)cin>>B[i];
int cntB = 0;
for(int i=1;i<=2*n;i++){
if(A[i]<=B[i]){
if(A[i]>=val[i-1])val[i]=A[i];
else if(B[i]>=val[i-1]){
chosen[i]=true;
val[i]=B[i];
cntB++;
} else {
cout << "-1\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |