Submission #505041

#TimeUsernameProblemLanguageResultExecution timeMemory
505041Jarif_Rahman여별 열쇠 (JOI15_keys)C++17
10 / 100
1084 ms336 KiB
#include <bits/stdc++.h> #define pb push_back #define f first #define sc second using namespace std; typedef long long int ll; typedef string str; const int inf = 1e9+1; int mn = inf; int n, m, k; vector<pair<int, int>> events; vector<pair<int, int>> pp; vector<pair<int, int>> ss; void bf(int in){ if(in == n){ if(ss.size() != k) return; set<int> s; for(int i = 0; i < k; i++) s.insert(ss[i].f), s.insert(ss[i].sc); int cur = 0; for(int i: s) cur+=events[i+1].f-events[i].f; mn = min(mn, cur); return; } ss.pb(pp[in]); bf(in+1); ss.pop_back(); bf(in+1); } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m >> k; k = n-k; for(int i = 0; i < n; i++){ int x, y; cin >> x >> y; events.pb({x, i+1}); events.pb({y, -i-1}); } sort(events.begin(), events.end()); pp.resize(n); for(int i = 0; i < 2*n; i++){ if(events[i].sc > 0) pp[events[i].sc-1].f = i; else pp[-events[i].sc-1].sc = i-1; } int ans = m; bf(0); ans-=mn; cout << ans << "\n"; }

Compilation message (stderr)

keys.cpp: In function 'void bf(int)':
keys.cpp:19:22: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   19 |         if(ss.size() != k) return;
      |            ~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...