Submission #703367

#TimeUsernameProblemLanguageResultExecution timeMemory
703367AestivateSelf Study (JOI22_ho_t2)C++17
35 / 100
1077 ms13316 KiB
#include<bits/stdc++.h> #include<random> using namespace std; template<typename T> void _do(T x){cerr<<x<<"\n";} template<typename T,typename ...U> void _do(T x,U ...y){cerr<<x<<", ";_do(y...);} #define dbg(...) cerr<<#__VA_ARGS__<<" = ";_do(__VA_ARGS__); #define float double #define ss(n) fixed<<setprecision(n) #define ll long long #define int ll #define IO ios::sync_with_stdio(false);cin.tie(0); #define ld long double #define pb push_back #define pii pair<int,int> #define rep(i,a) for(int i=1;i<=a;i++) #define rep0(i,a) for(int i=0;i<a;i++) #define F first #define S second #define uni(a) a.resize(distance(a.begin(),unique(a.begin(),a.end()))); #define unisort(a) sort(a.begin(),a.end()); uni(a); ll gcd(ll a,ll b){if(b==0) return a; return gcd(b,a%b);} const ld pi=3.14159265358979323846264338327950288419716939931; const int lar=3e18; const int mol1=1e9+7; const int mol2=998244353; const int MX=3e5; void solve() { int n,m; cin>>n>>m; int a[n+1],b[n+1]; rep(i,n) cin>>a[i]; rep(i,n) cin>>b[i]; priority_queue<pair<int,int>,vector<pair<int,int>>,greater<>>now; rep(i,n) now.push({0,i});int vis[n+1]={0}; rep(i,m){ rep(j,n) vis[j]=0; rep(j,n){ pair<int,int>kk=now.top(); if(vis[kk.S]==0){ kk.F+=max(a[kk.S],b[kk.S]); vis[kk.S]=1; } else { kk.F+=b[kk.S]; } now.pop(); now.push(kk); } } cout<<now.top().F<<"\n"; } signed main() { IO solve(); 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...