답안 #226004

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

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

    /// folosesti cele mai mari nr rame

    p2 = m;

    for (i = n ; i ; i--){
        if (v[i].second <= w[p2])
            p2--;
        if (p2 == m - nr)
            return 1;
    }

    return 0;

}

int main()
{
    FILE *fin = stdin;
    FILE *fout = stdout;
    int i , st , dr , mid;
    fscanf (fin,"%d%d",&n,&m);
    for (i = 1 ; i <= n ; i++){
        fscanf (fin,"%d%d",&v[i].second,&v[i].first);
    }
    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 , -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:31: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:33: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,&v[i].first);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:36: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 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 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 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 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 6 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 6 ms 384 KB Output is correct
27 Correct 6 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Correct 5 ms 384 KB Output is correct
35 Correct 5 ms 384 KB Output is correct
36 Correct 5 ms 384 KB Output is correct
37 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 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 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 6 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 6 ms 384 KB Output is correct
27 Correct 6 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Correct 5 ms 384 KB Output is correct
35 Correct 5 ms 384 KB Output is correct
36 Correct 5 ms 384 KB Output is correct
37 Correct 5 ms 384 KB Output is correct
38 Correct 81 ms 5112 KB Output is correct
39 Correct 82 ms 5232 KB Output is correct
40 Correct 80 ms 5240 KB Output is correct
41 Correct 83 ms 5120 KB Output is correct
42 Correct 81 ms 5240 KB Output is correct
43 Correct 81 ms 5240 KB Output is correct
44 Correct 83 ms 5240 KB Output is correct
45 Correct 89 ms 5240 KB Output is correct
46 Correct 83 ms 5112 KB Output is correct
47 Correct 85 ms 4728 KB Output is correct
48 Correct 78 ms 4728 KB Output is correct
49 Correct 74 ms 4088 KB Output is correct
50 Correct 69 ms 4088 KB Output is correct
51 Correct 90 ms 5240 KB Output is correct
52 Correct 89 ms 5240 KB Output is correct
53 Correct 90 ms 5240 KB Output is correct
54 Correct 67 ms 5368 KB Output is correct
55 Correct 77 ms 5244 KB Output is correct
56 Correct 59 ms 3832 KB Output is correct
57 Correct 33 ms 1656 KB Output is correct
58 Correct 52 ms 3832 KB Output is correct
59 Correct 60 ms 3832 KB Output is correct
60 Correct 33 ms 1784 KB Output is correct
61 Correct 60 ms 2936 KB Output is correct
62 Correct 95 ms 5240 KB Output is correct
63 Correct 93 ms 5240 KB Output is correct
64 Correct 95 ms 5240 KB Output is correct
65 Correct 101 ms 5308 KB Output is correct
66 Correct 102 ms 5368 KB Output is correct
67 Correct 102 ms 5240 KB Output is correct
68 Correct 94 ms 5240 KB Output is correct
69 Correct 96 ms 5240 KB Output is correct
70 Correct 102 ms 5240 KB Output is correct
71 Correct 96 ms 5112 KB Output is correct
72 Correct 100 ms 5240 KB Output is correct
73 Correct 92 ms 5240 KB Output is correct