Codeforces Round #202 (Div. 2)

时间:2023-03-09 07:04:49
Codeforces Round #202 (Div. 2)

第一题水题但是wa了一发,排队记录下收到的25,50,100,看能不能找零,要注意100可以找25*3

复杂度O(n)

第二题贪心,先找出最小的花费,然后就能得出最长的位数,然后循环对每个位上的数看能不能加上剩余的油漆比现在这数大,输出即可

复杂度O(10n)

By , contest: Codeforces Round # (Div. ), problem: (B) Color the Fence, Accepted, #
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define MIN(a,b) a<b ? a:b using namespace std; const double g=10.0,eps=1e-;
const int N=+,maxn=+,inf=0x3f3f3f; int a[N];
int main()
{
ios::sync_with_stdio(false);
cin.tie();
int n,minn=N,id;
cin>>n;
for(int i=;i<;i++)
{
cin>>a[i];
if(minn>=a[i])
{
minn=a[i];
id=i;
}
}
if(minn>n)
{
cout<<-<<endl;
return ;
}
int le=n%minn;
for(int i=;i<=(n-n%minn)/minn;i++)
{
int maxx=id;
if(le==)
{
cout<<id;
continue;
}
for(int j=;j<;j++)
if(le+minn>=a[j]&&j>maxx)
maxx=max(maxx,j);
cout<<maxx;
le-=(a[maxx]-minn);
}
cout<<endl;
return ;
}

b题

第三题推公式,一个多小时还是没做出来

Let the answer be x games. Notice that max(a1, a2, …, an) ≤ x. Then i-th player can be game supervisor in xai games. If we sum up we get Codeforces Round #202 (Div. 2) — it's the number of games in which players are ready to be supervisor. This number must be greater or equal to x — our answer.

Codeforces Round #202 (Div. 2)

Codeforces Round #202 (Div. 2)

Codeforces Round #202 (Div. 2)

Codeforces Round #202 (Div. 2)

Don't forget about that condition: max(a1, a2, …, an) ≤ x.

#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define MIN(a,b) a<b ? a:b using namespace std; const double g=10.0,eps=1e-;
const int N=+,maxn=+,inf=0x3f3f3f; ll a[N];
int main()
{
ios::sync_with_stdio(false);
cin.tie();
ll n,maxx=-,sum=;
cin>>n;
for(int i=;i<n;i++)
{
cin>>a[i];
sum+=a[i];
maxx=max(maxx,a[i]);
}
ll ans=maxx;
if(sum%(n-)==)cout<<max(sum/(n-),maxx)<<endl;
else cout<<max(sum/(n-)+,maxx)<<endl;
return ;
}

C

D,E现在水平不够,先放着