Submission #227772

#TimeUsernameProblemLanguageResultExecution timeMemory
227772NaynaExhibition (JOI19_ho_t2)C++14
100 / 100
99 ms4744 KiB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int,int>pii;
const int mxn = 1e5+5;

bool cmp(int a, int b)
{
    return a>b;
}
priority_queue<pii>pq;
int arr[mxn];

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);

    for(int i = 1; i <= n; i++)
    {
        int sz, value;
        scanf("%d%d", &sz, &value);
        pq.push(make_pair(value, sz));
    }
    for(int i = 1; i<= m; i++) scanf("%d", &arr[i]);
    sort(arr+1, arr+m+1, cmp);

    int ans = 0;
    for(int i = 1; i <= m; i++)
    {
        while(!pq.empty() && pq.top().second>arr[i]) pq.pop();
        if(pq.empty()) break;
        ans++;
        pq.pop();
    }
    printf("%d\n", ans);
    return 0;
}

Compilation message (stderr)

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:23:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &sz, &value);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:26:37: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 1; i<= m; i++) scanf("%d", &arr[i]);
                                ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...