Submission #842151

#TimeUsernameProblemLanguageResultExecution timeMemory
842151konberExam (eJOI20_exam)C++14
0 / 100
1 ms756 KiB
#include <iostream> #include <vector> using namespace std; vector<int> A, b; int N; int f(vector<int> a, int i){ if(i==N){ int ans=0; for(int j=0; j < N; j++) ans += a[j]==b[j]; return ans; } int j=i, k=i; bool changes=true; vector<int> a1=a, a2=a; while(changes){ changes = false; if(j >= 0 && a[j] <= b[i]){ a1[j] = b[i]; changes=true; j--; } if(k <= N-1 && a[k] <= b[i]){ a2[k] = b[i]; changes=true; k++; } if(j==0 && k==N-1) break; } return max(f(a, i+1), max(f(a1, i+1), f(a2, i+1))); } int main() { scanf("%d", &N); A.resize(N); b.resize(N); for(int i=0; i < N; i++) scanf("%d", &A[i]); for(int i=0; i < N; i++) scanf("%d", &b[i]); if(N <= 10){ cout << f(A, 0) << endl; } }

Compilation message (stderr)

exam.cpp: In function 'int main()':
exam.cpp:38:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |     scanf("%d", &N);
      |     ~~~~~^~~~~~~~~~
exam.cpp:42:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |         scanf("%d", &A[i]);
      |         ~~~~~^~~~~~~~~~~~~
exam.cpp:44:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |         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...