Submission #463521

#TimeUsernameProblemLanguageResultExecution timeMemory
463521kilikumaExam (eJOI20_exam)C++14
0 / 100
1083 ms716 KiB
#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)

exam.cpp: In function 'int main()':
exam.cpp:73:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   73 |   scanf("%d",&nbEleves);
      |   ~~~~~^~~~~~~~~~~~~~~~
exam.cpp:76:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   76 |     scanf("%d",&A[i]);
      |     ~~~~~^~~~~~~~~~~~
exam.cpp:79:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   79 |     scanf("%d",&B[i]);
      |     ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...