Submission #1451955


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#define int long long

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

int n, m;
pair<int, int> xy[100000 + 5];
int a[100000 + 5];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    rep(i, n) {
        cin >> xy[i].fi;
        cin >> xy[i].se;
    }
    rep(i, m) cin >> a[i];
    sort(xy, xy + n);
    sort(a, a + m);
    int now = 0;
    priority_queue<int, vector<int>, greater<int>> pq;
    int ans = 0;
    rep(i, m) {
        while (now < n && xy[now].fi <= a[i]) {
            pq.push(xy[now].se);
            now++;
        }
        while (!pq.empty()) {
            int y = pq.top(); pq.pop();
            if (a[i] <= y) {
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
}

Submission Info

Submission Time
Task D - 枕決め
User roto_37
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1581 Byte
Status AC
Exec Time 48 ms
Memory 3068 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 20
Set Name Test Cases
All 00-sample-00, 00-sample-01, 00-sample-02, 10-random-00, 10-random-01, 10-random-02, 10-random-03, 10-random-04, 10-random-05, 10-random-06, 10-random-07, 10-random-08, 10-random-09, 20-random_max-00, 20-random_max-01, 20-random_max-02, 20-random_max-03, 20-random_max-04, 30-corner-00, 30-corner-01
Case Name Status Exec Time Memory
00-sample-00 AC 1 ms 256 KB
00-sample-01 AC 1 ms 256 KB
00-sample-02 AC 1 ms 256 KB
10-random-00 AC 35 ms 2556 KB
10-random-01 AC 23 ms 1664 KB
10-random-02 AC 32 ms 2176 KB
10-random-03 AC 20 ms 1408 KB
10-random-04 AC 45 ms 3068 KB
10-random-05 AC 23 ms 1536 KB
10-random-06 AC 19 ms 1280 KB
10-random-07 AC 25 ms 1664 KB
10-random-08 AC 9 ms 768 KB
10-random-09 AC 19 ms 1280 KB
20-random_max-00 AC 48 ms 2944 KB
20-random_max-01 AC 48 ms 2944 KB
20-random_max-02 AC 47 ms 2944 KB
20-random_max-03 AC 48 ms 2944 KB
20-random_max-04 AC 48 ms 2944 KB
30-corner-00 AC 18 ms 2044 KB
30-corner-01 AC 14 ms 1408 KB