답안 #225991

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
225991 2020-04-22T09:17:58 Z Ruxandra985 Exhibition (JOI19_ho_t2) C++14
10 / 100
6 ms 768 KB
#include <bits/stdc++.h>
#define DIMN 100010
using namespace std;
int w[DIMN] , f[DIMN];
pair <int,pair <int,int> > v[DIMN];
pair <int , int> p[DIMN];
int n , m;

int check (int nr){
    int i , p2;

    memset (f , 0 , sizeof(f));

    for (i = 1 ; i <= nr ; i++){
        f[-p[i].second] = 1;
    }

    p2 = m;

    for (i = n ; i ; i--){
        if (f[i]){

            if (w[p2] < v[i].second.first)
                return 0;

            p2--;

        }
    }
    return 1;

}

int main()
{
    FILE *fin = stdin;
    FILE *fout = stdout;
    int i , st , dr , mid , ed = 0;
    fscanf (fin,"%d%d",&n,&m);
    for (i = 1 ; i <= n ; i++){
        fscanf (fin,"%d%d",&v[i].second.first,&v[i].first);
        v[i].second.second = i;
    }
    for (i = 1 ; i <= m ; i++)
        fscanf (fin,"%d",&w[i]);

    sort (v + 1 , v + n + 1);
    sort (w + 1 , w + m + 1);

    for (i = 1 ; i <= n ; i++)
        p[i] = make_pair(v[i].second.first , -i);

    sort (p + 1 , p + n + 1);

    st = 1;
    dr = min (n , m);
    while (st <= dr){
        mid = (st + dr) / 2;
        if (check(mid))
            st = mid + 1;
        else dr = mid - 1;
    }

    fprintf (fout,"%d",dr);

    return 0;
}

Compilation message

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:38:29: warning: unused variable 'ed' [-Wunused-variable]
     int i , st , dr , mid , ed = 0;
                             ^~
joi2019_ho_t2.cpp:39:12: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     fscanf (fin,"%d%d",&n,&m);
     ~~~~~~~^~~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:41:16: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         fscanf (fin,"%d%d",&v[i].second.first,&v[i].first);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:45:16: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         fscanf (fin,"%d",&w[i]);
         ~~~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 768 KB Output is correct
2 Correct 5 ms 768 KB Output is correct
3 Correct 5 ms 768 KB Output is correct
4 Correct 5 ms 640 KB Output is correct
5 Correct 5 ms 768 KB Output is correct
6 Correct 5 ms 768 KB Output is correct
7 Correct 5 ms 768 KB Output is correct
8 Correct 6 ms 768 KB Output is correct
9 Correct 6 ms 768 KB Output is correct
10 Correct 5 ms 768 KB Output is correct
11 Correct 5 ms 768 KB Output is correct
12 Correct 5 ms 768 KB Output is correct
13 Correct 5 ms 768 KB Output is correct
14 Correct 5 ms 768 KB Output is correct
15 Correct 5 ms 768 KB Output is correct
16 Correct 5 ms 768 KB Output is correct
17 Correct 5 ms 768 KB Output is correct
18 Correct 5 ms 768 KB Output is correct
19 Correct 5 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 768 KB Output is correct
2 Correct 5 ms 768 KB Output is correct
3 Correct 5 ms 768 KB Output is correct
4 Correct 5 ms 640 KB Output is correct
5 Correct 5 ms 768 KB Output is correct
6 Correct 5 ms 768 KB Output is correct
7 Correct 5 ms 768 KB Output is correct
8 Correct 6 ms 768 KB Output is correct
9 Correct 6 ms 768 KB Output is correct
10 Correct 5 ms 768 KB Output is correct
11 Correct 5 ms 768 KB Output is correct
12 Correct 5 ms 768 KB Output is correct
13 Correct 5 ms 768 KB Output is correct
14 Correct 5 ms 768 KB Output is correct
15 Correct 5 ms 768 KB Output is correct
16 Correct 5 ms 768 KB Output is correct
17 Correct 5 ms 768 KB Output is correct
18 Correct 5 ms 768 KB Output is correct
19 Correct 5 ms 768 KB Output is correct
20 Correct 6 ms 768 KB Output is correct
21 Correct 6 ms 768 KB Output is correct
22 Correct 6 ms 768 KB Output is correct
23 Correct 5 ms 768 KB Output is correct
24 Correct 6 ms 768 KB Output is correct
25 Incorrect 6 ms 768 KB Output isn't correct
26 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 768 KB Output is correct
2 Correct 5 ms 768 KB Output is correct
3 Correct 5 ms 768 KB Output is correct
4 Correct 5 ms 640 KB Output is correct
5 Correct 5 ms 768 KB Output is correct
6 Correct 5 ms 768 KB Output is correct
7 Correct 5 ms 768 KB Output is correct
8 Correct 6 ms 768 KB Output is correct
9 Correct 6 ms 768 KB Output is correct
10 Correct 5 ms 768 KB Output is correct
11 Correct 5 ms 768 KB Output is correct
12 Correct 5 ms 768 KB Output is correct
13 Correct 5 ms 768 KB Output is correct
14 Correct 5 ms 768 KB Output is correct
15 Correct 5 ms 768 KB Output is correct
16 Correct 5 ms 768 KB Output is correct
17 Correct 5 ms 768 KB Output is correct
18 Correct 5 ms 768 KB Output is correct
19 Correct 5 ms 768 KB Output is correct
20 Correct 6 ms 768 KB Output is correct
21 Correct 6 ms 768 KB Output is correct
22 Correct 6 ms 768 KB Output is correct
23 Correct 5 ms 768 KB Output is correct
24 Correct 6 ms 768 KB Output is correct
25 Incorrect 6 ms 768 KB Output isn't correct
26 Halted 0 ms 0 KB -