Submission #1351346

#TimeUsernameProblemLanguageResultExecution timeMemory
1351346dex111222333444555Exhibition (JOI19_ho_t2)C++20
100 / 100
29 ms3704 KiB
#include <bits/stdc++.h>
#define all(v) begin(v), end(v)
#define ii pair<int, int>
#define fi first
#define se second
#define siz(v) (int)(v).size()
#define lli pair<long long, int>
#define dbg(x) "[" #x " = " << x << "]"
#define BIT(x, i) (((x) >> (i)) & 1)
#define MASK(i) (1LL << (i))

using namespace std;

const long long inf = 1e18 + 123;
const int mod = 1e9 + 7, infINT = 1e9 + 1321;

template<class X, class Y> bool minimize(X &x, const Y &y){return x > y ? x = y, 1: 0;}
template<class X, class Y> bool maximize(X &x, const Y &y){return x < y ? x = y, 1: 0;}

const int MAXN = 1e5 + 5;

#define int long long

int numVal, numQuery, query[MAXN];
ii val[MAXN];
vector<int > comp;

void input(){
    cin >> numVal >> numQuery;
    for(int i = 1; i <= numVal; i++) cin >> val[i].fi >> val[i].se;
    for(int q = 1; q <= numQuery; q++) cin >> query[q], comp.push_back(query[q]);
}

int getPos(const int &pos){
    return lower_bound(all(comp), pos) - begin(comp) + 1;
}

bool cmp(const ii &a, const ii &b){
    if (a.se == b.se) return a.fi > b.fi;
    return a.se > b.se;
}

void solve(){
    sort(val + 1, val + 1 + numVal, cmp);
    sort(query + 1, query + 1 + numQuery, greater<int>());

    int j = 1, res = 0;
    for(int i = 1; i <= numQuery; i++){
        while(j <= numVal && query[i] < val[j].fi) j++;
        if (j <= numVal){
            res++;
            j++;
        }
    }
    cout << res << '\n';
}

signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define task "test"
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    input();
    solve();
    cerr << (1.0 * clock()) / CLOCKS_PER_SEC << ".s\n";
}

Compilation message (stderr)

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:62:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   62 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:63:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...