# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
463521 | 2021-08-11T09:41:42 Z | kilikuma | Exam (eJOI20_exam) | C++14 | 1000 ms | 716 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Incorrect | 1 ms | 276 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1083 ms | 332 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1079 ms | 716 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Incorrect | 1 ms | 276 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Incorrect | 1 ms | 276 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |