Submission #1046258

#TimeUsernameProblemLanguageResultExecution timeMemory
1046258NickpapadakExam (eJOI20_exam)C++17
0 / 100
3 ms2652 KiB
#include<bits/stdc++.h> using namespace std; #define MAXN 100010 #define INF 1000000010 #define ll long long ll N, B[MAXN]; ll A[MAXN]; pair<ll,ll> Range[MAXN]; ll solveEQ(){ ll ans = 0; ll i = 1, j =1; bool foundB = false; for(;j<=N;++j){ if(A[j] > B[1]) { ans += (j-i) * foundB; i= j+1; foundB = false; } else if(A[j] == B[1]) foundB= true; } return ans; } void setRange(){ A[0] = INF; A[N+1] = INF; for(ll i =1;i<=N;++i){ ll j =i,k =i; while(A[j-1] <= A[i] || A[k+1] <=A[i]){ if(A[j-1] <= A[i]) --j; if(A[k+1] <= A[i]) ++k; } Range[i] = {j,k}; } } ll solveSORT(){ ll ans =0; for(ll i = 1;i<=N;++i){ for(ll j = Range[i].first; j<=Range[i].second; ++j){ if(B[j] == A[i]) ans++; } } return ans; } int main(){ scanf("%d",&N); for(ll i=1;i<=N;++i){ scanf("%d",&A[i]); } bool AllB = true; for(ll i =1;i<=N;++i){ scanf("%d",&B[i]); if(B[i] != B[i-1] && i > 1) AllB = false; } if(AllB) printf("%d\n", solveEQ()); else if(is_sorted(A+1, A+N+1)){ setRange(); printf("%d\n", solveSORT()); } return 0; }

Compilation message (stderr)

exam.cpp: In function 'int main()':
exam.cpp:50:13: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   50 |     scanf("%d",&N);
      |            ~^  ~~
      |             |  |
      |             |  long long int*
      |             int*
      |            %lld
exam.cpp:52:17: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   52 |         scanf("%d",&A[i]);
      |                ~^  ~~~~~
      |                 |  |
      |                 |  long long int*
      |                 int*
      |                %lld
exam.cpp:56:17: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   56 |         scanf("%d",&B[i]);
      |                ~^  ~~~~~
      |                 |  |
      |                 |  long long int*
      |                 int*
      |                %lld
exam.cpp:60:18: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
   60 |         printf("%d\n", solveEQ());
      |                 ~^     ~~~~~~~~~
      |                  |            |
      |                  int          long long int
      |                 %lld
exam.cpp:63:18: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
   63 |         printf("%d\n", solveSORT());
      |                 ~^     ~~~~~~~~~~~
      |                  |              |
      |                  int            long long int
      |                 %lld
exam.cpp:50:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |     scanf("%d",&N);
      |     ~~~~~^~~~~~~~~
exam.cpp:52:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |         scanf("%d",&A[i]);
      |         ~~~~~^~~~~~~~~~~~
exam.cpp:56:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |         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...