Submission #206942

# Submission time Handle Problem Language Result Execution time Memory
206942 2020-03-06T00:58:52 Z joylintp Exhibition (JOI19_ho_t2) C++17
0 / 100
5 ms 504 KB
#include<bits/stdc++.h>
using namespace std;

#define INF 1000000000

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> p(n);
    vector<int> f(m);
    for (int i = 0; i < n; i++)
        cin >> p[i].second >> p[i].first;
    for (int i = 0; i < m; i++)
        cin >> f[i];
    sort(p.begin(), p.end()), sort(f.begin(), f.end());

    vector<int> lis;
    vector<vector<pair<int, int>>> v;
    for (int i = 0; i < n; i++)
    {
        int pos = lower_bound(f.begin(), f.end(), p[i].second) - f.begin();
        if (pos == m)
            continue;

        int owo = upper_bound(lis.begin(), lis.end(), pos) - lis.begin();
        if (owo == lis.size())
            lis.push_back(pos), v.push_back({{i, pos}});
        else
            lis[owo] = pos, v[owo].push_back({i, pos});
    }

    /*for (auto vv : v)
    {
        for (auto i : vv)
            cout << i.first << ' ' << i.second << "  ";
        cout << '\n';
    }*/

    if (lis.empty())
        cout << "0\n";
    else if (lis.size() == 1)
        cout << "1\n";
    else
    {
        int ans = 0;
        for (auto p : *v.rbegin())
        {
            int mxm = prev(upper_bound(v[0].begin(), v[0].end(), make_pair(p.first, INF))) -> second;
            ans = max(ans, min((int)lis.size(), m - mxm));
        }
        cout << ans << '\n';
    }

    return 0;
}

//      *   *  *****  *   *  *   *
//     *   *  *      **  *  *   *
//    *****  *****  * * *  *   *
//   *   *      *  *  **  *   *
//  *   *  *****  *   *   ***

//      ***** ***** *   * *     ***** *   * ***** *****
//        *  *   * *   * *       *   **  *   *   *   *
//       *  *   * ***** *       *   * * *   *   *****
//   *  *  *   *   *   *       *   *  **   *   *
//  ****  *****   *   ***** ***** *   *   *   *

Compilation message

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:30:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (owo == lis.size())
             ~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Incorrect 5 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Incorrect 5 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Incorrect 5 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -