Submission #120135

#TimeUsernameProblemLanguageResultExecution timeMemory
120135Just_Solve_The_ProblemExhibition (JOI19_ho_t2)C++11
100 / 100
114 ms6712 KiB
#include <bits/stdc++.h> #define ll long long #define ok puts("OK"); using namespace std; const int N = (int)3e5 + 7; int n, m; int s[N], v[N], c[N], pos[N]; main() { iota(pos, pos + N, 0); scanf("%d %d", &n, &m); vector <int> vec; for (int i = 1; i <= n; i++) { scanf("%d %d", &s[i], &v[i]); vec.push_back(s[i]); } for (int i = 1; i <= m; i++) { scanf("%d", &c[i]); vec.push_back(c[i]); } sort(vec.begin(), vec.end()); vec.resize(unique(vec.begin(), vec.end()) - vec.begin()); for (int i = 1; i <= n; i++) { s[i] = lower_bound(vec.begin(), vec.end(), s[i]) - vec.begin() + 1; } for (int i = 1; i <= m; i++) { c[i] = lower_bound(vec.begin(),vec.end(), c[i]) - vec.begin() + 1; } sort(pos + 1, pos + n + 1, [&](const int &A, const int &B) { if (v[A] == v[B]) { return s[A] < s[B]; } return v[A] < v[B]; }); sort(c + 1, c + m + 1); int cur = n; int ans = 0; for (int i = m; i >= 1 && cur > 0; i--) { while (cur > 0 && s[pos[cur]] > c[i]) { cur--; } ans += (cur > 0); cur--; } cout << ans; }

Compilation message (stderr)

joi2019_ho_t2.cpp:13:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:15:8: 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:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &s[i], &v[i]);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &c[i]);
     ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...