Submission #1145854

#TimeUsernameProblemLanguageResultExecution timeMemory
1145854andrewpSelf Study (JOI22_ho_t2)C++20
35 / 100
1093 ms13488 KiB
//Dedicated to my love, ivaziva #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define pii pair<int,int> #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define sz(a) ((int)a.size()) const int N=3e5+5; ll n, m; ll a[N], b[N]; int main () { ios::sync_with_stdio(false), cin.tie(0); cin >> n >> m; for (ll i=1; i<=n; i++) cin >> a[i]; for (ll i=1; i<=n; i++) cin >> b[i]; priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq; for (ll i=1; i<=n; i++) { pq.push(make_pair(0ll, i)); } for (ll j=1; j<=m; j++) { for (ll i=1; i<=n; i++) { auto x=pq.top(); pq.pop(); if (x.second==i) x.first+=max(a[i], b[i]); else x.first+=b[x.second]; pq.push(x); } } cout << pq.top().first << '\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...
#Verdict Execution timeMemoryGrader output
Fetching results...