第一题水题但是wa了一发,排队记录下收到的25,50,100,看能不能找零,要注意100可以找25*3
复杂度O(n)
第二题贪心,先找出最小的花费,然后就能得出最长的位数,然后循环对每个位上的数看能不能加上剩余的油漆比现在这数大,输出即可
复杂度O(10n)
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
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; }
第三题推公式,一个多小时还是没做出来
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.
![](http://codeforces.com/predownloaded/6b/47/6b4709c404b7eb49a78dda2ba9449cda124cad6f.png)
![](http://codeforces.com/predownloaded/a8/b2/a8b207bb71123d7b46d667e5f96d2a57602b527f.png)
![](http://codeforces.com/predownloaded/39/e4/39e48d1be67754f27324d830f848d9dc3c39dde0.png)
![](http://codeforces.com/predownloaded/b8/b1/b8b1cffbf6036a4a514e8ca5cbb547d6d069982a.png)
Don't forget about that condition: max(a1, a2, …, an) ≤ x.
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#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; }
D,E现在水平不够,先放着