Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- //ifstream fin("permuta.in");
- //ofstream fout("permuta.out");
- #define f first
- #define s second
- #define pb push_back
- #define FOR(i,a,b) for(i=(a);i<=(b);++i)
- #define FORS(i,a,b) for(i=(a);i<(b);++i)
- #define vpp vector<pair<int,int>>
- #define ll long long
- #define maxn 200005
- ll sol;
- int main()
- {
- // freopen("subsecvente2.in","r",stdin);
- // freopen("subsecvente2.out","w",stdout);
- int i,n,m,k,maxi=-1,maxi2=-1,x,cnt;
- cin>>n>>m>>k;
- for(i=1;i<=n;++i){
- cin>>x;
- if(x>maxi){
- if(maxi2<maxi)
- maxi2=maxi;
- maxi=x;
- }
- else if(x>maxi2)
- maxi2=x;
- }
- cnt=m/(k+1);
- sol=(1LL*cnt*k*maxi)+(1LL*cnt*maxi2);
- cnt=(m%(k+1));
- sol+=(1LL*cnt*maxi);
- cout<<sol;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement