Submission #885241

#TimeUsernameProblemLanguageResultExecution timeMemory
885241raul2008487Matryoshka (JOI16_matryoshka)C++17
51 / 100
2017 ms11472 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back #define eb emplace_back #define vl vector<ll> #define fi first #define se second #define in insert #define mpr make_pair #define lg(x) __lg(x) #define bpc(x) __builtin_popcount(x) #define all(v) v.begin(), v.end() #define endl "\n" using namespace std; const int sz = 2e5+5; /// sz is changed const int mod = 1e9+7; const ll inf = 10000000000; void solve(){ ll n, q, i, j, x, y; cin>>n>>q; vl a(n), h(n); vector<pair<ll,ll>> v; for(i=0;i<n;i++){ cin>>a[i]>>h[i]; v.pb({a[i], h[i]}); } sort(all(v)); while(q--){ cin>>x>>y; auto lx = lower_bound(all(v), mpr(x, 0*1LL)); ll ix = (lx - v.begin()); multiset<ll> ms; vector<pair<ll,ll>> ad; for(i = ix; i<n; i++){ if(v[i].se <= y){ if(ad.size() && ad.back().fi != v[i].fi){ for(j=0;j<ad.size();j++){ ms.in(ad[j].se); } ad.clear(); } auto x = ms.lower_bound(v[i].se); if(x != ms.begin()){ x--; ms.erase(x); } ad.pb(v[i]); } } for(j=0;j<ad.size();j++){ ms.in(ad[j].se); } cout << ms.size() << endl; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); //precomp(); ll tst=1; //cin>>tst; while(tst--){ solve(); } } /* 7 3 9 5 3 7 10 6 5 10 2 6 10 10 4 1 10 5 3 5 3 9 */

Compilation message (stderr)

matryoshka.cpp: In function 'void solve()':
matryoshka.cpp:37:30: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |                     for(j=0;j<ad.size();j++){
      |                             ~^~~~~~~~~~
matryoshka.cpp:50:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |         for(j=0;j<ad.size();j++){
      |                 ~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...