Submission #2224347


Source Code Expand

Copy
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i, n) for(int i = n - 1; i >= 0; i--)
#define REP2(i, n, k) for(int i = 0; i < n; i += k)



int main() {
    int n;
    set<int> s;
    bool f[200] = {};
    vector<pair<int, int>> v;
    
    cin >> n;
    REP(i, n){
        int a, b;
        cin >> a >> b;
        v.push_back({a, b});
        f[a] = true;
    }
    REP(i, n){
        int c, d;
        cin >> c >> d;
        v.push_back({c, d});
    }
    
    sort(v.begin(), v.end());
    
    int ans = 0;
    REP(i, 2 * n){
        if(f[v[i].first]){
            s.insert(v[i].second);
        }
        else{
            int t = -1;
            for(auto x : s){
                if(x < v[i].second){
                    t = max(t, x);
                }
            }
            if(t != -1){
                s.erase(t);
                ans++;
            }
        }
    }
    
    cout << ans << endl;
}

Submission Info

Submission Time
Task C - 2D Plane 2N Points
User chocobo
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1417 Byte
Status
Exec Time 1 ms
Memory 256 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 example_0, example_1, example_2, example_3, example_4
All 400 / 400 example_0, example_1, example_2, example_3, example_4, line_0, line_1, line_2, line_3, maxrand_0, maxrand_1, maxrand_2, maxrand_3, maxrand_4, rand_0, rand_1, rand_2
Case Name Status Exec Time Memory
example_0 1 ms 256 KB
example_1 1 ms 256 KB
example_2 1 ms 256 KB
example_3 1 ms 256 KB
example_4 1 ms 256 KB
line_0 1 ms 256 KB
line_1 1 ms 256 KB
line_2 1 ms 256 KB
line_3 1 ms 256 KB
maxrand_0 1 ms 256 KB
maxrand_1 1 ms 256 KB
maxrand_2 1 ms 256 KB
maxrand_3 1 ms 256 KB
maxrand_4 1 ms 256 KB
rand_0 1 ms 256 KB
rand_1 1 ms 256 KB
rand_2 1 ms 256 KB