Submission #777279

#TimeUsernameProblemLanguageResultExecution timeMemory
777279OzyAkcija (COCI21_akcija)C++17
30 / 110
2 ms568 KiB
#include <iostream> #include <bits/stdc++.h> using namespace std; #define lli long long int #define rep(i,a,b) for(int i = (a); i <= (b); i++) #define repa(i,a,b) for(int i = (a); i >= (b); i--) #define debug(a) cout << #a << " = " << a << endl #define debugsl(a) cout << #a << " = " << a << ", " #define pll pair<lli,lli> //para el vector de orden #define w first #define d second lli a,b,res,cant,n,k; vector<pll> orden; set<lli> dispo; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> k; rep(i,1,n) { cin >> a >> b; orden.push_back({a,b}); } sort(orden.begin(), orden.end()); repa(i,n,1) dispo.emplace_hint(dispo.end(), -i); res = 0; cant = 0; for (auto act : orden) { auto it = dispo.lower_bound(-act.d); if (it == dispo.end()) continue; cant++; res += act.w; dispo.erase(it); } cout << cant << ' ' << res; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...