Codeforces Round #216 (Div. 2)解题报告
又范低级错误!
只做了两题!一道还被HACK了,囧!
A:看了很久!应该是到语文题:
代码:#include<iostream>
#include<string.h>
using namespace std;
int main()
{
int n,m,k;
cin>>n>>m>>k;
int a[10000];
int m1=0,m2=0;
for (int i=1;i<=n;i++)
{
cin>>a[i];
if (a[i]==1) m1++;
else m2++;
}
int ans=0;
if (m>=m1) ans=m1+m2-m-k;
else
{
ans=m1-m;
if (k<m2) ans+=m2-k;
}
if (ans<0) ans=0;
cout<<ans<<endl;
return 0;
using namespace std;
int main()
{
int n,m,k;
cin>>n>>m>>k;
int a[10000];
int m1=0,m2=0;
for (int i=1;i<=n;i++)
{
cin>>a[i];
if (a[i]==1) m1++;
else m2++;
}
int ans=0;
if (m>=m1) ans=m1+m2-m-k;
else
{
ans=m1-m;
if (k<m2) ans+=m2-k;
}
if (ans<0) ans=0;
cout<<ans<<endl;
return 0;
}
写的超级垃圾!反正就是乱搞!
B题:又是一类构建题!先用SK构建好啊A[1]--->A[K];先每个都初始化为L;
然后从A[1]-->A[K]递加,这里最好用除法,加法的太慢会TLE,
A[K+1]-->A[N]其实类似。
#include<iostream>
using namespace std;
int a[10000];
int main()
{
int n,k,l,r,sa,sk;
cin>>n>>k>>l>>r>>sa>>sk;
int div=sk/k;//a[1]-a[k]
int mod=sk%k;
for (int i=1;i<=k;i++)
a[i]=div;
while (mod)
{
for (int i=1;i<=k;i++)
{
if (mod==0) break;
mod--;
a[i]++;
}
}
sa=sa-sk-(n-k)*l;
for (int i=k+1;i<=n;i++) a[k+1]-a[n]
a[i]=l;
if (n-k!=0)//很重要,可能N==K,我就是挂在上面
{
div=sa/(n-k);
mod=sa%(n-k);
}
for (int i=k+1;i<=n;i++)
a[i]+=div;
while (mod)
{
for (int i=k+1;i<=n;i++)
{
if (mod==0) break;
mod--;
a[i]++;
}
}
cout<<a[1];
for (int i=2;i<=n;i++)
cout<<" "<<a[i];
cout<<endl;
return 0;
using namespace std;
int a[10000];
int main()
{
int n,k,l,r,sa,sk;
cin>>n>>k>>l>>r>>sa>>sk;
int div=sk/k;//a[1]-a[k]
int mod=sk%k;
for (int i=1;i<=k;i++)
a[i]=div;
while (mod)
{
for (int i=1;i<=k;i++)
{
if (mod==0) break;
mod--;
a[i]++;
}
}
sa=sa-sk-(n-k)*l;
for (int i=k+1;i<=n;i++) a[k+1]-a[n]
a[i]=l;
if (n-k!=0)//很重要,可能N==K,我就是挂在上面
{
div=sa/(n-k);
mod=sa%(n-k);
}
for (int i=k+1;i<=n;i++)
a[i]+=div;
while (mod)
{
for (int i=k+1;i<=n;i++)
{
if (mod==0) break;
mod--;
a[i]++;
}
}
cout<<a[1];
for (int i=2;i<=n;i++)
cout<<" "<<a[i];
cout<<endl;
return 0;
}
很无语!昨天心情不好,加上CF写挂!
随性Code