Submission #257326

# Submission time Handle Problem Language Result Execution time Memory
257326 2020-08-04T06:03:57 Z 문홍윤(#5062) None (JOI16_worst_reporter2) C++17
0 / 100
1 ms 384 KB
#include <bits/stdc++.h>
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define svec(x) sort(x.begin(), x.end())
#define press(x) x.erase(unique(x.begin(), x.end()), x.end())
#define lb(x, v) lower_bound(x.begin(), x.end(), v)
#define ub(x, v) upper_bound(x.begin(), x.end(), v)
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
const LL llinf=2000000000000000000;
const LL mod1=1000000007;
const LL mod2=998244353;
const int inf=2000000000;

int n, ans;
pii a[200010], b[200010];
int cnt[200010];
bool ch[200010];
vector<int> vc;

int main(){
    scanf("%d", &n);
    for(int i=1; i<=n; i++)scanf("%d %d", &a[i].S, &a[i].F);
    for(int i=1; i<=n; i++)scanf("%d %d", &b[i].S, &b[i].F);
    sort(a+1, a+n+1);
    sort(b+1, b+n+1);
    int pv=1, num=0;
    for(int i=1; i<=n; i++){
        for(; pv<=n; pv++){
            if(a[pv].F>b[i].F)break;
            num++;
        }
        if(num==i)ch[i]=true;
        if(num<i)return !printf("-1");
    }
    pv=1, ans=n;
    for(int i=1; i<=n; i++){
        for(; pv<=n; pv++){
            if(a[pv].F>b[i].F)break;
            cnt[a[pv].S]++;
            vc.eb(a[pv].S);
        }
        if(cnt[b[i].S]){
            cnt[b[i].S]--;
            ans--;
        }
        if(ch[i]){
            for(auto i:vc)cnt[i]=0;
            vc.clear();
        }
    }
    printf("%d", ans);
}

/*
6
1 70
4 50
1 30
2 20
1 10
3 0
6 100
2 90
1 80
2 60
4 40
1 10
*/

Compilation message

worst_reporter2.cpp: In function 'int main()':
worst_reporter2.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
worst_reporter2.cpp:30:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1; i<=n; i++)scanf("%d %d", &a[i].S, &a[i].F);
                            ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
worst_reporter2.cpp:31:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1; i<=n; i++)scanf("%d %d", &b[i].S, &b[i].F);
                            ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Incorrect 1 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Incorrect 1 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Incorrect 1 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Incorrect 1 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -