This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define ioss ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back
int n, m;
vector<pii> gambar;
bool comp(pii a, pii b) {
return (a.fi < b.fi || (a.fi == b.fi && a.se < b.se));
}
signed main() {
ioss;
cin >> n >> m;
for(int i = 0; i < n; i++) {
int s, v; cin >> s >> v;
gambar.pb({s, v});
}
sort(gambar.begin(), gambar.end(), comp);
vector<pii> img;
img.pb({gambar[0].fi, gambar[0].se});
for(int i = 1; i < n; i++) {
auto [s, v] = gambar[i];
auto [ps, pv] = gambar[i-1];
if(pv > v) continue;
img.pb({s, v});
}
vector<int> bingkai;
for(int i = 0; i < m; i++) {
int x; cin >> x;
bingkai.pb(x);
}
int tmp = 0, ans = 0;
for(auto size : bingkai) {
auto [s, v] = img[tmp];
if(s <= size) ans++, tmp++;
if(tmp == img.size()) break;
// cout << " :: " << s << " " << size << " " << ans << endl;
}
cout << ans << endl;
}
Compilation message (stderr)
joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:40:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | if(tmp == img.size()) break;
| ~~~~^~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |