Advertisement
Alhiris

Untitled

Feb 18th, 2019
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. //ifstream fin("permuta.in");
  4. //ofstream fout("permuta.out");
  5. #define f first
  6. #define s second
  7. #define pb push_back
  8. #define FOR(i,a,b) for(i=(a);i<=(b);++i)
  9. #define FORS(i,a,b) for(i=(a);i<(b);++i)
  10. #define vpp vector<pair<int,int>>
  11. #define ll long long
  12. #define maxn 200005
  13.  
  14. ll sol;
  15.  
  16. int main()
  17. {
  18. //  freopen("subsecvente2.in","r",stdin);
  19. //  freopen("subsecvente2.out","w",stdout);
  20.     int i,n,m,k,maxi=-1,maxi2=-1,x,cnt;
  21.     cin>>n>>m>>k;
  22.     for(i=1;i<=n;++i){
  23.         cin>>x;
  24.         if(x>maxi){
  25.             if(maxi2<maxi)
  26.             maxi2=maxi;
  27.             maxi=x;
  28.         }
  29.         else if(x>maxi2)
  30.             maxi2=x;
  31.     }
  32.     cnt=m/(k+1);
  33.     sol=(1LL*cnt*k*maxi)+(1LL*cnt*maxi2);
  34.     cnt=(m%(k+1));
  35.     sol+=(1LL*cnt*maxi);
  36.     cout<<sol;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement