Submission #995466

# Submission time Handle Problem Language Result Execution time Memory
995466 2024-06-09T06:40:37 Z SuPythony Exhibition (JOI19_ho_t2) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int n,m; cin>>n>>m;
    vector<pair<int,int>> a;
    for (int i=0; i<n; i++) {
        int s,v; cin>>s>>v;
        a.push_back({v,s});
    }
    vector<int> c(m);
    for (auto &i: c) cin>>i;
    sort(a.begin(),a.end());
    sort(c.begin(),c.end());
    vector<int> s;
    for (auto i: a) s.push_back(i.second);
    vector<int> lbs;
    for (int i=0; i<n; i++) {
        auto p=lower_bound(c.begin(),c.end(),s[i]);
        if (p==c.end()) continue;
        lbs.push_back(p-c.begin());
    }
    vector<int> l;
    int mn;
    for (int i=0; i<lbs.size(); i++) {
        auto p=upper_bound(l.begin(),l.end(),lbs[i]);
        if (p==l.end()) {
            l.push_back(lbs[i]);
            mn=lbs[0];
        } else {
            *p=lbs[i];
        }
    }
    cout<<min(m-mn,(int)l.size());
}

Compilation message

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:26:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for (int i=0; i<lbs.size(); i++) {
      |                   ~^~~~~~~~~~~
joi2019_ho_t2.cpp:35:16: warning: 'mn' may be used uninitialized in this function [-Wmaybe-uninitialized]
   35 |     cout<<min(m-mn,(int)l.size());
      |               ~^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 1 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 1 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 1 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -