답안 #51051

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
51051 2018-06-15T17:49:13 Z SpaimaCarpatilor Matryoshka (JOI16_matryoshka) C++17
51 / 100
2000 ms 1948 KB
#include<bits/stdc++.h>

using namespace std;

int nr, N, Q, h[100009];
pair < int, int > v[100009];

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &Q);
for (int i=1; i<=N; i++)
    scanf ("%d %d", &v[i].first, &v[i].second), v[i].second = -v[i].second;
sort (v + 1, v + N + 1);
for (int i=1; i<=N; i++)
    v[i].second = -v[i].second;
while (Q --)
{
    int X, Y;
    scanf ("%d %d", &X, &Y), nr = 0;
    for (int i=1; i<=N; i++)
        if (v[i].first >= X && v[i].second <= Y)
            h[++nr] = v[i].second;
    multiset < int > S;
    for (int i=1; i<=nr; i++)
    {
        auto it = S.lower_bound (h[i]);
        if (it == S.begin ()) S.insert (h[i]);
        else
        {
            it --;
            S.erase (it), S.insert (h[i]);
        }
    }
    printf ("%d\n", S.size ());
}
return 0;
}

Compilation message

matryoshka.cpp: In function 'int main()':
matryoshka.cpp:37:30: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::multiset<int>::size_type {aka long unsigned int}' [-Wformat=]
     printf ("%d\n", S.size ());
                     ~~~~~~~~~^
matryoshka.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf ("%d %d", &N, &Q);
 ~~~~~~^~~~~~~~~~~~~~~~~
matryoshka.cpp:15:47: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%d %d", &v[i].first, &v[i].second), v[i].second = -v[i].second;
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
matryoshka.cpp:22:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%d %d", &X, &Y), nr = 0;
     ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 2 ms 688 KB Output is correct
6 Correct 2 ms 688 KB Output is correct
7 Correct 3 ms 688 KB Output is correct
8 Correct 2 ms 688 KB Output is correct
9 Correct 2 ms 688 KB Output is correct
10 Correct 2 ms 688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 2 ms 688 KB Output is correct
6 Correct 2 ms 688 KB Output is correct
7 Correct 3 ms 688 KB Output is correct
8 Correct 2 ms 688 KB Output is correct
9 Correct 2 ms 688 KB Output is correct
10 Correct 2 ms 688 KB Output is correct
11 Correct 2 ms 688 KB Output is correct
12 Correct 2 ms 688 KB Output is correct
13 Correct 3 ms 688 KB Output is correct
14 Correct 3 ms 688 KB Output is correct
15 Correct 3 ms 688 KB Output is correct
16 Correct 3 ms 688 KB Output is correct
17 Correct 2 ms 688 KB Output is correct
18 Correct 3 ms 688 KB Output is correct
19 Correct 3 ms 688 KB Output is correct
20 Correct 2 ms 688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 2 ms 688 KB Output is correct
6 Correct 2 ms 688 KB Output is correct
7 Correct 3 ms 688 KB Output is correct
8 Correct 2 ms 688 KB Output is correct
9 Correct 2 ms 688 KB Output is correct
10 Correct 2 ms 688 KB Output is correct
11 Correct 2 ms 688 KB Output is correct
12 Correct 2 ms 688 KB Output is correct
13 Correct 3 ms 688 KB Output is correct
14 Correct 3 ms 688 KB Output is correct
15 Correct 3 ms 688 KB Output is correct
16 Correct 3 ms 688 KB Output is correct
17 Correct 2 ms 688 KB Output is correct
18 Correct 3 ms 688 KB Output is correct
19 Correct 3 ms 688 KB Output is correct
20 Correct 2 ms 688 KB Output is correct
21 Correct 3 ms 688 KB Output is correct
22 Correct 42 ms 748 KB Output is correct
23 Correct 168 ms 780 KB Output is correct
24 Correct 69 ms 780 KB Output is correct
25 Correct 203 ms 832 KB Output is correct
26 Correct 79 ms 832 KB Output is correct
27 Correct 66 ms 832 KB Output is correct
28 Correct 208 ms 832 KB Output is correct
29 Correct 184 ms 832 KB Output is correct
30 Correct 199 ms 1000 KB Output is correct
31 Correct 160 ms 1000 KB Output is correct
32 Correct 172 ms 1000 KB Output is correct
33 Correct 156 ms 1000 KB Output is correct
34 Correct 160 ms 1000 KB Output is correct
35 Correct 181 ms 1000 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 2 ms 688 KB Output is correct
6 Correct 2 ms 688 KB Output is correct
7 Correct 3 ms 688 KB Output is correct
8 Correct 2 ms 688 KB Output is correct
9 Correct 2 ms 688 KB Output is correct
10 Correct 2 ms 688 KB Output is correct
11 Correct 2 ms 688 KB Output is correct
12 Correct 2 ms 688 KB Output is correct
13 Correct 3 ms 688 KB Output is correct
14 Correct 3 ms 688 KB Output is correct
15 Correct 3 ms 688 KB Output is correct
16 Correct 3 ms 688 KB Output is correct
17 Correct 2 ms 688 KB Output is correct
18 Correct 3 ms 688 KB Output is correct
19 Correct 3 ms 688 KB Output is correct
20 Correct 2 ms 688 KB Output is correct
21 Correct 3 ms 688 KB Output is correct
22 Correct 42 ms 748 KB Output is correct
23 Correct 168 ms 780 KB Output is correct
24 Correct 69 ms 780 KB Output is correct
25 Correct 203 ms 832 KB Output is correct
26 Correct 79 ms 832 KB Output is correct
27 Correct 66 ms 832 KB Output is correct
28 Correct 208 ms 832 KB Output is correct
29 Correct 184 ms 832 KB Output is correct
30 Correct 199 ms 1000 KB Output is correct
31 Correct 160 ms 1000 KB Output is correct
32 Correct 172 ms 1000 KB Output is correct
33 Correct 156 ms 1000 KB Output is correct
34 Correct 160 ms 1000 KB Output is correct
35 Correct 181 ms 1000 KB Output is correct
36 Execution timed out 2054 ms 1948 KB Time limit exceeded
37 Halted 0 ms 0 KB -