Submission #417294

#TimeUsernameProblemLanguageResultExecution timeMemory
417294lycEvent Hopping 2 (JOI21_event2)C++14
0 / 100
30 ms1484 KiB
#include <bits/stdc++.h> using namespace std; #define TRACE(x) cerr << #x << " :: " << x << endl #define _ << " " << #define SZ(x) ((int)(x).size()) #define ALL(x) (x).begin(), (x).end() #define FOR(i,a,b) for(int i=(a);i<=(b);++i) #define RFOR(i,a,b) for(int i=(a);i>=(b);--i) typedef long long ll; typedef pair<int,int> ii; const int mxN = 1e5+5; const int mxK = 1e5+5; int N, K; ii events[mxN]; int dp[mxN]; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> N >> K; FOR(i,1,N){ int L, R; cin >> L >> R; events[i] = ii(L,R); } dp[N+1] = 0; dp[N] = 1; RFOR(i,N-1,1){ auto it = lower_bound(events+1,events+1+N,ii(events[i].second,0))-events; dp[i] = dp[it]+1; } vector<int> ans; FOR(i,1,N){ if (ans.empty() || events[ans.back()].second <= events[i].first) { if (SZ(ans) + dp[i] >= K) { ans.push_back(i); } } if (SZ(ans) == K) break; } if (SZ(ans) < K) { cout << -1 << '\n'; } else { for (int& x : ans) { cout << x << '\n'; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...