# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
463521 | kilikuma | Exam (eJOI20_exam) | C++14 | 1083 ms | 716 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;
int nbEleves;
int maxi = 0; int A[100000+42]; int etat[100000+42]; int B[100000+42];
int C[100000+42];
void recur(int N) {
if (N == nbEleves+1) {
for (int i=1;i<=nbEleves;i++) C[i] = A[i];
int objectif = 0;
for (int i=1;i<=nbEleves; i++) {
if (etat[i]) objectif ++;
}
bool cond =true;
for (int i=1; i<= nbEleves;i++) {
if (etat[i]) {
// if(objectif==4) cout << i << endl;
int maxiCur = 0;
bool cond1 = false;
for (int j=i; j<=nbEleves; j++) {
maxiCur = max(maxiCur, C[j]);
if (maxiCur == B[i]) {
cond1 = true;
for (int z = i; z <= j; z ++) {
C[i] = B[i];
}
// if(etat[1] && etat[2] && etat[4]) cout << i << " " << j << endl;
break;
}
}
if (!cond1) {
maxiCur = C[i];
for (int j=i-1; j>=1 ; j--) {
if (etat[j]) break;
maxiCur = max(maxiCur, C[j]);
if (maxiCur == B[i]) {
cond1 = true;
for (int z = j; z >= i; z --) {
C[i] = B[i];
}
// if(etat[1] && etat[2] && etat[4])
// cout << i << " " << j << endl;
break;
}
}
}
if (!cond1) {
cond = false;
}
}
}
if (cond) {
/* if(objectif==4) {
for (int i=1;i<=nbEleves; i++) {
cout << etat[i] << endl;
}
} */
maxi = max(maxi, objectif);
}
}
else {
etat[N] = false;
recur(N+1);
etat[N] = true;
recur(N+1);
etat[N] = false;
}
}
int main() {
scanf("%d",&nbEleves);
for (int i = 1; i<= nbEleves; i++) {
scanf("%d",&A[i]);
}
for (int i=1;i<=nbEleves; i++) {
scanf("%d",&B[i]);
}
for (int i=1;i<=nbEleves; i++) {
etat[i] = false;
}
recur(1);
printf("%d\n", maxi);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |