Submission #970586

# Submission time Handle Problem Language Result Execution time Memory
970586 2024-04-26T17:59:20 Z hariaakas646 Exhibition (JOI19_ho_t2) C++14
0 / 100
0 ms 344 KB
#include <bits/stdc++.h>

using namespace std;

#define scd(t) scanf("%d", &t)
#define sclld(t) scanf("%lld", &t)
#define forr(i, j, k) for (int i = j; i < k; i++)
#define frange(i, j) forr(i, 0, j)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<lli> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long double ld;


void usaco()
{
    freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin);
//    freopen("problem.out", "w", stdout);
}

int n, m;
vii vec;
vi sz;

bool check(int x) {
    mseti st;
    int id = 0;
    int ma = 0;
    for(int i=x; i>=0; i--) {
        int v = sz[i];
        while(id < n && vec[id].f <= v) {
            if(vec[id].s >= ma)
                st.insert(vec[id].s);
            id++;
        }
        if(!st.size()) return false;
        // printf("%d %d\n", i, *st.begin());
        ma = max(ma, *st.begin());
        st.erase(st.begin());
    }
    return true;

}

int main() {
    // usaco();
    scd(n);
    scd(m);
    vec = vii(n);
    sz = vi(m);

    frange(i, n) {
        scd(vec[i].f);
        scd(vec[i].s);
    }

    frange(i, m) {
        scd(sz[i]);
    }

    sort(all(vec));
    sort(all(sz), greater<>());

    int lo = 0;
    int hi = m-1;

    while(lo != hi) {
        int mid = (lo+hi+1)/2;
        // printf("%d %d\n", lo, hi);
        if(check(mid)) {
            lo = mid;
        }
        else {
            hi = mid-1;
        }
    }
    printf("%d\n", lo+1);
}

Compilation message

joi2019_ho_t2.cpp: In function 'void usaco()':
joi2019_ho_t2.cpp:30:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |     freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
joi2019_ho_t2.cpp:60:5: note: in expansion of macro 'scd'
   60 |     scd(n);
      |     ^~~
joi2019_ho_t2.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
joi2019_ho_t2.cpp:61:5: note: in expansion of macro 'scd'
   61 |     scd(m);
      |     ^~~
joi2019_ho_t2.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
joi2019_ho_t2.cpp:66:9: note: in expansion of macro 'scd'
   66 |         scd(vec[i].f);
      |         ^~~
joi2019_ho_t2.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
joi2019_ho_t2.cpp:67:9: note: in expansion of macro 'scd'
   67 |         scd(vec[i].s);
      |         ^~~
joi2019_ho_t2.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
joi2019_ho_t2.cpp:71:9: note: in expansion of macro 'scd'
   71 |         scd(sz[i]);
      |         ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -