Codeforces Round #202 (Div. 2)
第一题水题但是wa了一发,排队记录下收到的25,50,100,看能不能找零,要注意100可以找25*3
复杂度O(n)
第二题贪心,先找出最小的花费,然后就能得出最长的位数,然后循环对每个位上的数看能不能加上剩余的油漆比现在这数大,输出即可
复杂度O(10n)
By 2016326603147, contest: Codeforces Round #202 (Div. 2), 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-9; const int N=100000+10,maxn=10000+10,inf=0x3f3f3f; int a[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); int n,minn=N,id; cin>>n; for(int i=1;i<10;i++) { cin>>a[i]; if(minn>=a[i]) { minn=a[i]; id=i; } } if(minn>n) { cout<<-1<<endl; return 0; } int le=n%minn; for(int i=1;i<=(n-n%minn)/minn;i++) { int maxx=id; if(le==0) { cout<<id; continue; } for(int j=1;j<10;j++) if(le+minn>=a[j]&&j>maxx) maxx=max(maxx,j); cout<<maxx; le-=(a[maxx]-minn); } cout<<endl; return 0; }
b题
第三题推公式,一个多小时还是没做出来
Let the answer be x games. Notice that max(a1,?a2,?…,?an)?≤?x. Then i-th player can be game supervisor in x–ai games. If we sum up we get — 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.
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-9; const int N=100000+10,maxn=10000+10,inf=0x3f3f3f; ll a[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); ll n,maxx=-1,sum=0; cin>>n; for(int i=0;i<n;i++) { cin>>a[i]; sum+=a[i]; maxx=max(maxx,a[i]); } ll ans=maxx; if(sum%(n-1)==0)cout<<max(sum/(n-1),maxx)<<endl; else cout<<max(sum/(n-1)+1,maxx)<<endl; return 0; }
C
D,E现在水平不够,先放着
时间: 2024-10-14 00:09:14