Submission #206943

# Submission time Handle Problem Language Result Execution time Memory
206943 2020-03-06T01:15:24 Z joylintp Exhibition (JOI19_ho_t2) C++17
0 / 100
5 ms 376 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> ff;
    for (int i = 0; i < n; i++)
    {
        int t = lower_bound(f.begin(), f.end(), p[i].second) - f.begin();
        if (t == m)
            continue;
        ff.push_back(lower_bound(f.begin(), f.end(), p[i].second) - f.begin());
    }

    int ans = 0;
    for (int i = 0; i < ff.size(); i++)
    {
        vector<int> lis;
        for (int j = i; j < ff.size(); j++)
        {
            auto pos = upper_bound(lis.begin(), lis.end(), ff[j]);
            if (pos == lis.end())
                lis.push_back(ff[j]);
            else
                *pos = ff[j];
        }
        ans = max(ans, min(m - ff[i], (int)lis.size()));
    }
    cout << ans << '\n';

    return 0;
}

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

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

Compilation message

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:31:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < ff.size(); i++)
                     ~~^~~~~~~~~~~
joi2019_ho_t2.cpp:34:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = i; j < ff.size(); j++)
                         ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 4 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 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 4 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 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Incorrect 5 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -