Submission #1111401

#TimeUsernameProblemLanguageResultExecution timeMemory
1111401StefanSebezGift Exchange (JOI24_ho_t4)C++14
50 / 100
2574 ms9260 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define ll long long #define ld long double const int N=5e5+50,inf=1e9; int a[N],b[N],c[2*N]; int main(){ int n;scanf("%i",&n); for(int i=1;i<=n;i++) scanf("%i",&a[i]); for(int i=1;i<=n;i++) scanf("%i",&b[i]),c[b[i]]=a[i]; int q;scanf("%i",&q); while(q--){ int l,r;scanf("%i%i",&l,&r); vector<int>A,B; for(int i=l;i<=r;i++) A.pb(a[i]),B.pb(b[i]); B.pb(inf); sort(A.begin(),A.end()),sort(B.begin(),B.end()); //for(auto i:A) printf("%i ",i);printf("\n"); //for(auto i:B) printf("%i ",i);printf("\n"); int m=A.size(); bool res=true; for(int i=m-1,j=m-1;i>=0;i--){ while(j>=0&&A[j]>B[i]) j--;j++; if(i<j||(i==j&&B[i+1]>c[B[i]])) res=false; //printf("%i: %i\n",i,j); } if(res) printf("Yes\n"); else printf("No\n"); } return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:26:4: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   26 |    while(j>=0&&A[j]>B[i]) j--;j++;
      |    ^~~~~
Main.cpp:26:31: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
   26 |    while(j>=0&&A[j]>B[i]) j--;j++;
      |                               ^
Main.cpp:11:16: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     int n;scanf("%i",&n);
      |           ~~~~~^~~~~~~~~
Main.cpp:12:32: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     for(int i=1;i<=n;i++) scanf("%i",&a[i]);
      |                           ~~~~~^~~~~~~~~~~~
Main.cpp:13:32: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     for(int i=1;i<=n;i++) scanf("%i",&b[i]),c[b[i]]=a[i];
      |                           ~~~~~^~~~~~~~~~~~
Main.cpp:14:16: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     int q;scanf("%i",&q);
      |           ~~~~~^~~~~~~~~
Main.cpp:16:16: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   int l,r;scanf("%i%i",&l,&r);
      |           ~~~~~^~~~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...