Submission #1009242

#TimeUsernameProblemLanguageResultExecution timeMemory
1009242AiperiiiSelf Study (JOI22_ho_t2)C++14
35 / 100
1045 ms15012 KiB
#include <bits/stdc++.h> #define int long long #define all(x) x.begin(),x.end() #define ff first #define ss second #define pb push_back using namespace std; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); int n,m; cin>>n>>m; vector <int> a(n),b(n); for(int i=0;i<n;i++)cin>>a[i]; for(int i=0;i<n;i++)cin>>b[i]; if(m==1){ int res=1e9; for(int i=0;i<n;i++){ res=min(res,max(a[i],b[i])); } cout<<res<<"\n"; } else{ set <pair <int,int> > st; for(int i=0;i<n;i++){ st.insert({max(a[i],b[i]),i}); } for(int i=0;i<m*n-n;i++){ int x=st.begin()->ff; int id=st.begin()->ss; st.erase(st.begin()); x+=max(a[id],b[id]); st.insert({x,id}); } cout<<st.begin()->ff<<"\n"; } } /* 4 25 1 2 3 4 1 2 3 4 3 3 19 4 5 2 6 2 */
#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...