#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define fi first
#define se second
using namespace std;
int n, m;
const int maxn = 2e6;
const int inf = 1e9;
pll p[maxn + 3];
ll c[maxn + 3], ans;
bool vis[maxn + 3];
bool cmp(pll a, pll b)
{
if(a.se == b.se) return a.fi < b.fi;
return a.se < b.se;
}
int main()
{
// freopen("EXHIBITION.INP", "r", stdin);
// freopen("EXHIBITION.OUT", "w", stdout);
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
for(int i = 1; i <= n; i++)
{
cin >> p[i].fi >> p[i].se;
}
sort(p + 1, p + n + 1, cmp);
for(int i = 1; i <= m; i++)
{
cin >> c[i];
}
sort(c + 1, c + n + 1);
ll tmp = inf;
for(int i = n; i >= 1; i--)
{
int l = 1, r = m, res = 0, mid = 0;
while(l <= r)
{
mid = (l + r) / 2;
if(c[mid] >= p[i].fi && !vis[mid] && tmp >= c[mid])
{
l = mid + 1;
res = mid;
}
else l = mid + 1;
}
if(res != 0)
{
ans ++;
vis[res] == true;
tmp = c[res];
}
}
cout << ans;
}
Compilation message
joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:56:22: warning: statement has no effect [-Wunused-value]
56 | vis[res] == true;
| ~~~~~~~~~^~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4560 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4560 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4560 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |