답안 #218076

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
218076 2020-04-01T05:10:47 Z KoalaMuch Exhibition (JOI19_ho_t2) C++14
0 / 100
5 ms 384 KB
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
struct A
{
    int sz,v;
    bool operator<(const A&o)const
    {
        if(v!=o.v)    return v<o.v;
        return sz<o.sz;
    }
};
A a[N];
int b[N];
int dp[N];
int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i=1;i<=n;i++)   scanf("%d %d",&a[i].sz,&a[i].v);
    for(int i=1;i<=m;i++)   scanf("%d",&b[i]);
    sort(a+1,a+n+1); sort(b+1,b+m+1);
    int l = 0,r = n;
    while(l<r)
    {
        int mid = (l+r+1) >> 1,len = 0;
        for(int i=1;i<=n;i++)
        {
            int idx = upper_bound(dp,dp+len,a[i].sz)-dp;
            if(a[i].sz<=b[m-mid+idx+1])
            {
                if(idx==len)  ++len;
                dp[idx] = a[i].sz;
            }
        }
        if(len>=mid)  l=mid;
        else          r=mid-1;
    }
    printf("%d\n",l);
    return 0;
}
/*
3 4
10 20
5 1
3 5
4 6 10 4

8 8
508917604 35617051
501958939 840246141
485338402 32896484
957730250 357542366
904165504 137209882
684085683 775621730
552953629 20004459
125090903 607302990
433255278
979756183
28423637
856448848
276518245
314201319
666094038
149542543
*/

Compilation message

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&n,&m);
     ~~~~~^~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:20:34: 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].sz,&a[i].v);
                             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:21:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1;i<=m;i++)   scanf("%d",&b[i]);
                             ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Incorrect 5 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Incorrect 5 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Incorrect 5 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -