Submission #1032431

#TimeUsernameProblemLanguageResultExecution timeMemory
1032431AndreyGift Exchange (JOI24_ho_t4)C++14
50 / 100
2590 ms4692 KiB
#include<bits/stdc++.h> using namespace std; bool check(vector<pair<int,int>> haha) { sort(haha.begin(),haha.end()); vector<int> su(haha.size()+1,INT_MAX); for(int i = haha.size()-1; i >= 0; i--) { su[i] = min(su[i+1],haha[i].second); } for(int i = 0; i < haha.size(); i++) { if((i == 0 || haha[i-1].first < haha[i].second) && su[i+1] > haha[i].first) { return false; } } return true; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n,q,l,r; cin >> n; vector<int> a(n+1); vector<int> b(n+1); for(int i = 1; i <= n; i++) { cin >> a[i]; } for(int i = 1; i <= n; i++) { cin >> b[i]; } cin >> q; for(int i = 0; i < q; i++) { cin >> l >> r; vector<pair<int,int>> haha(0); for(int j = l; j <= r; j++) { haha.push_back({a[j],b[j]}); } if(check(haha)) { cout << "Yes\n"; } else { cout << "No\n"; } } return 0; }

Compilation message (stderr)

Main.cpp: In function 'bool check(std::vector<std::pair<int, int> >)':
Main.cpp:10:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for(int i = 0; i < haha.size(); 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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...