Submission #788754

#TimeUsernameProblemLanguageResultExecution timeMemory
788754stefanneaguSelf Study (JOI22_ho_t2)C++17
62 / 100
1075 ms27392 KiB
#include <iostream> #include <set> #define int long long using namespace std; const int nmax = 3e5 + 7; int v[nmax], b[nmax], cnt[nmax]; struct pairing { int first, second; const bool operator < (pairing a) const { if(first != a.first) { return first < a.first; } else { return second > a.second; } } }; int32_t main() { int n, k; cin >> n >> k; for(int i = 1; i <= n; i ++) { cin >> v[i]; } for(int i = 1; i <= n; i ++){ cin >> b[i]; } set<pairing> pq; for(int i = 1; i <= n; i ++) { pq.insert({max(v[i], b[i]), i}); cnt[i] = 1; } for(int i = 2; i <= k; i ++) { for(int j = 1; j <= n; j ++) { pairing curr = *(pq.begin()); int sum = curr.first, ind = curr.second; pq.erase({sum, ind}); if(cnt[ind] < k) { sum += max(v[ind], b[ind]); cnt[ind] ++; } else { sum += b[ind]; } pq.insert({sum, ind}); } } int minn = 1e18; for(auto it : pq) { // cout << it.first << " " << it.second << endl; minn = min(minn, it.first); } cout << minn; 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...