Submission #878742

# Submission time Handle Problem Language Result Execution time Memory
878742 2023-11-25T07:01:49 Z frostray8653 Exhibition (JOI19_ho_t2) C++17
0 / 100
1 ms 2808 KB
#include <bits/stdc++.h>
#define int long long
#define IO ios::sync_with_stdio(0), cin.tie(0)
#define FOR(i, a, b) for (int i = a, I = b; i <= I; i++)
using namespace std;
using pii = pair<int, int>;
void dbg() {;}
template<class T, class ...U>
void dbg(T a, U ...b) { cout << a << " "; dbg(b...); }
void ent() { cout << "\n"; }

const int N = 100005;
pii a[N];
int c[N];

signed main() {
    IO;

    int n, m;
    cin >> n >> m;
    FOR(i, 0, n - 1) cin >> a[i].first >> a[i].second;
    FOR(i, 0, m - 1) cin >> c[i];
    sort(a, a + n, [&](pii p, pii q) {
        if (p.first != q.first)
            return p.first > q.first;
        return p.second > q.second;
    });
    sort(c, c + m, greater<int>());

    int ans = 0;
    for (int mask = 0; mask < (1 << n); mask++) {
        bool fg = true;
        vector<int> v;
        for (int i = 0; i < n; i++) {
            if (mask & (1 << i))
                v.push_back(a[i].second);
        }
        for (int i = 0; i + 1 < v.size(); i++)
            if (v[i] < v[i + 1]) {
                fg = false;
                break;
            }
        if (v.size() > m)
            fg = false;
        if (! fg)
            continue;
        int id = 0;
        for (int i = 0; i < n; i++) {
            if (mask & (1 << i)) {
                if (a[i].first > c[id]) {
                    fg = false;
                    break;
                }
                id += 1;
            }
        }
        if (! fg)
            continue;
        ans = max(ans, (int)v.size());
    }

    cout << ans << "\n";

    return 0;
}
/*
1 1
100 5
10
*/

Compilation message

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:38:31: 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]
   38 |         for (int i = 0; i + 1 < v.size(); i++)
      |                         ~~~~~~^~~~~~~~~~
joi2019_ho_t2.cpp:43:22: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   43 |         if (v.size() > m)
      |             ~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2808 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Incorrect 1 ms 2396 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2808 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Incorrect 1 ms 2396 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2808 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Incorrect 1 ms 2396 KB Output isn't correct
6 Halted 0 ms 0 KB -