A. Copy-paste (thinking)

https://codeforces.com/contest/1417/problem/A


Idea: After sort, copy the smallest number to each of the following numbers and count the total. This total is the largest and optimal.

#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=1e3+100;
typedef long long LL;
LL a[maxn]; 
int main(void)
{
  cin.tie(0);std::ios::sync_with_stdio(false);
  LL t;cin>>t;
  while(t--)
  {
  	LL n,k;cin>>n>>k;
  	for(LL i=1;i<=n;i++) cin>>a[i];
  	sort(a+1,a+1+n);
  	LL sum=0;
  	for(LL i=2;i<=n;i++)
  	{
  		sum+=((k-a[i])/a[1]);
	}
	cout<<sum<<endl;
  }
return 0;
}

 

Guess you like

Origin blog.csdn.net/zstuyyyyccccbbbb/article/details/108854732