Submission #51051

#TimeUsernameProblemLanguageResultExecution timeMemory
51051SpaimaCarpatilorMatryoshka (JOI16_matryoshka)C++17
51 / 100
2054 ms1948 KiB
#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 (stderr)

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;
     ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...