답안 #799684

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
799684 2023-07-31T20:08:17 Z n3rm1n Exhibition (JOI19_ho_t2) C++17
0 / 100
1 ms 320 KB
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAXN = 1e5 + 10;
void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int n, m;
vector < pair < int , int > > g;
vector < int > frames;
void read()
{
    cin >> n >> m;
    int xx, yy;
    for (int i = 1; i <= n; ++ i)
    {
        cin >> xx >> yy;
        g.push_back(make_pair(yy, xx));
    }
    sort(g.begin(), g.end());
    for (int i = 1; i <= m; ++ i)
    {
        cin >> xx;
        frames.push_back(-xx);
    }
    sort(frames.begin(), frames.end());
}
vector < int > v;
bool check(int goal)
{
    v.clear();
    v.push_back(-1);
    int x;
    int sz = goal;
    for (int i = 0; i < g.size(); ++ i)
    {
        x = g[i].second;
        //cout << x << endl;
        //cout << (int)v.back() << endl;
        if(x >= (int)v.back() && x <= -frames[sz-1])
        {
            v.push_back(x);
            //cout << "in " << x << endl;
            sz --;
        }
        else
        {
            vector < int >::iterator it = upper_bound(v.begin(), v.end(), x);
            if(it == v.end())continue;
            int num = *it, index = it - v.begin();
            v[index] = x;

        }
    }
   return (sz <= 0);
}
void bin_search()
{
    int l = 1, r = m, mid, ans = 0;
    while(l <= r)
    {
        mid = (l + r)/2;
        if(check(mid))
        {
            ans = mid;
            l = mid + 1;
        }
        else r = mid - 1;
    }
    cout << ans << endl;
}
int main()
{
    speed();

    read();
    bin_search();
    return 0;
}

Compilation message

joi2019_ho_t2.cpp: In function 'bool check(int)':
joi2019_ho_t2.cpp:38:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for (int i = 0; i < g.size(); ++ i)
      |                     ~~^~~~~~~~~~
joi2019_ho_t2.cpp:53:17: warning: unused variable 'num' [-Wunused-variable]
   53 |             int num = *it, index = it - v.begin();
      |                 ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -