답안 #367341

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
367341 2021-02-16T22:46:34 Z lookcook Exhibition (JOI19_ho_t2) C++17
0 / 100
0 ms 364 KB
#include <bits/stdc++.h>

#define int long long

using namespace std;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    map<pair<int,int>,int> cnt;
    vector<int> frames;
    vector<pair<int,int>> vec;
    priority_queue<pair<int,int>> pq;
    for (int i = 0; i < n; i++) {
        int s, v;
        cin >> s >> v;
        pq.push({v,s});
    }
    sort(vec.begin(),vec.end());
    for (int i = 0; i < m; i++) {
        int c;
        cin >> c;
        frames.push_back(c);
    }
    sort(frames.begin(),frames.end());
    reverse(frames.begin(),frames.end());
    int lstVal = 1e18;
    int res = 0;
    for (int i = 0; i < frames.size(); i++) {
        int c = frames[i];
        pair<int,int> best = {-1,-1};
        while (!pq.empty()) {
            pair<int,int> pa = pq.top();
            pq.pop();
            if (pa.second > c || pa.first > lstVal) continue;
            best = pa;
            break;
        }
        if (best.first != -1) {
            res++;
            lstVal = best.second;
            cnt[best]--;
            if (cnt[best] == 0) cnt.erase(best);
        }
    }
    cout << res << '\n';
}

Compilation message

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:31:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for (int i = 0; i < frames.size(); i++) {
      |                     ~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Incorrect 0 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Incorrect 0 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Incorrect 0 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -