A:签到。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<''||c>'')) c=getchar();return c;}
int gcd(int n,int m){return m==?n:gcd(m,n%m);}
int read()
{
int x=,f=;char c=getchar();
while (c<''||c>'') {if (c=='-') f=-;c=getchar();}
while (c>=''&&c<='') x=(x<<)+(x<<)+(c^),c=getchar();
return x*f;
}
int T;
int main()
{
T=read();
while (T--)
{
int a=read(),b=read(),k=read();
if (k&) cout<<1ll*(a-b)*(k>>)+a<<endl;
else cout<<1ll*(a-b)*(k>>)<<endl;
}
return ;
}

  B:将能提供2贡献的位置先取反再扫一遍即可。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define N 110
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<''||c>'')) c=getchar();return c;}
int gcd(int n,int m){return m==?n:gcd(m,n%m);}
int read()
{
int x=,f=;char c=getchar();
while (c<''||c>'') {if (c=='-') f=-;c=getchar();}
while (c>=''&&c<='') x=(x<<)+(x<<)+(c^),c=getchar();
return x*f;
}
int n,a[N],ans=;
int main()
{
n=read();
for (int i=;i<=n;i++) a[i]=read();
for (int i=;i<=n-;i++) if (a[i]==&&a[i-]==&&a[i+]==&&a[i-]==&&a[i+]==) ans++,a[i]=;
for (int i=;i<n;i++) if (a[i]==&&a[i-]==&&a[i+]==) ans++,a[i+]=;
cout<<ans;
return ;
}

  C:桶记录出现数字次数,枚举删掉的数字即可。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define N 200010
#define M 1000010
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<''||c>'')) c=getchar();return c;}
int gcd(int n,int m){return m==?n:gcd(m,n%m);}
int read()
{
int x=,f=;char c=getchar();
while (c<''||c>'') {if (c=='-') f=-;c=getchar();}
while (c>=''&&c<='') x=(x<<)+(x<<)+(c^),c=getchar();
return x*f;
}
int n,a[N],b[N],tot[M],cnt;
ll sum;
int main()
{
n=read();
for (int i=;i<=n;i++) sum+=a[i]=read(),tot[a[i]]++;
for (int i=;i<=n;i++)
{
ll x=sum-a[i];
if (x<=&&x%==&&tot[x/]>(a[i]==x/)) b[++cnt]=i;
}
cout<<cnt<<endl;
for (int i=;i<=cnt;i++) printf("%d ",b[i]);
return ;
}

  D:二分答案贪心选取即可。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define N 200010
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<''||c>'')) c=getchar();return c;}
int gcd(int n,int m){return m==?n:gcd(m,n%m);}
int read()
{
int x=,f=;char c=getchar();
while (c<''||c>'') {if (c=='-') f=-;c=getchar();}
while (c>=''&&c<='') x=(x<<)+(x<<)+(c^),c=getchar();
return x*f;
}
int n,m,cnt[N],id[N],ans[N];
struct data
{
int x,y;
bool operator <(const data&a) const
{
return y>a.y;
}
}a[N],b[N];
bool check(int k)
{
for (int i=;i<=;i++) b[i]=a[i];
int s=;
for (int i=;i<=;i++)
while (b[i].y>=k&&s<m) id[++s]=b[i].x,b[i].y-=k;
return s>=m;
}
int main()
{
n=read(),m=read();
for (int i=;i<=n;i++) cnt[read()]++;
for (int i=;i<=;i++) a[i].x=i,a[i].y=cnt[i];
sort(a+,a+);
int l=,r=n/m;
while (l<=r)
{
int mid=l+r>>;
if (check(mid)) {for (int i=;i<=m;i++) ans[i]=id[i];l=mid+;}
else r=mid-;
}
for (int i=;i<=m;i++) printf("%d ",ans[i]);
return ;
}

  E:枚举序列长度(显然是log级别的),二分首项大小,贪心选取即可。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define N 200010
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<''||c>'')) c=getchar();return c;}
int gcd(int n,int m){return m==?n:gcd(m,n%m);}
int read()
{
int x=,f=;char c=getchar();
while (c<''||c>'') {if (c=='-') f=-;c=getchar();}
while (c>=''&&c<='') x=(x<<)+(x<<)+(c^),c=getchar();
return x*f;
}
int n,a[N],b[N],cnt[N],tot;
bool check(int k,int s)
{
int t=;
for (int i=;i<=n;i++)
{
if (a[i]>=k) t++,k<<=;
if (t==s) return ;
}
return ;
}
int main()
{
n=read();
for (int i=;i<=n;i++) b[i]=a[i]=read();
sort(b+,b+n+);
int t=unique(b+,b+n+)-b-;
for (int i=;i<=n;i++) a[i]=lower_bound(b+,b+t+,a[i])-b;
for (int i=;i<=n;i++) cnt[a[i]]++;
sort(cnt+,cnt+t+);
for (int i=;i<=t;i++) a[i]=cnt[i];
int tmp=n;
n=t;
for (int i=;i<=;i++)
{
int l=,r=tmp,ans=;
while (l<=r)
{
int mid=l+r>>;
if (check(mid,i)) ans=mid,l=mid+;
else r=mid-;
}
tot=max(tot,ans*((<<i)-));
}
cout<<tot;
return ;
}

  F1:f[i][j]表示前i个数选取了j个且第i个被选的最大价值,转移枚举上次选哪个即可。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define N 5010
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<''||c>'')) c=getchar();return c;}
int gcd(int n,int m){return m==?n:gcd(m,n%m);}
int read()
{
int x=,f=;char c=getchar();
while (c<''||c>'') {if (c=='-') f=-;c=getchar();}
while (c>=''&&c<='') x=(x<<)+(x<<)+(c^),c=getchar();
return x*f;
}
int n,m,k,a[N];
ll f[N][N];
int main()
{
n=read(),k=read(),m=read();
for (int i=;i<=n;i++) a[i]=read();
memset(f,,sizeof(f));
f[][]=;
for (int i=;i<=n;i++)
{
for (int j=;j<=m;j++)
{
for (int x=i-;x>=max(,i-k);x--)
f[i][j]=max(f[i][j],f[x][j-]+a[i]);
}
}
for (int i=n-;i>=max(,n-k+);i--) f[n][m]=max(f[n][m],f[i][m]);
if (f[n][m]<) cout<<-;
else cout<<f[n][m];
return ;
}

  F2:在F1基础上单调队列优化即可。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define N 5010
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<''||c>'')) c=getchar();return c;}
int gcd(int n,int m){return m==?n:gcd(m,n%m);}
int read()
{
int x=,f=;char c=getchar();
while (c<''||c>'') {if (c=='-') f=-;c=getchar();}
while (c>=''&&c<='') x=(x<<)+(x<<)+(c^),c=getchar();
return x*f;
}
int n,m,k,a[N],q[N],head,tail;
ll f[N][N];
int main()
{
n=read(),k=read(),m=read();
for (int i=;i<=n;i++) a[i]=read();
memset(f,,sizeof(f));
f[][]=;
for (int j=;j<=m;j++)
{
head=,tail=;q[]=;
for (int i=;i<=n;i++)
{
while (head<tail&&q[head]<i-k) head++;
f[i][j]=f[q[head]][j-]+a[i];
while (head<=tail&&f[q[tail]][j-]<=f[i][j-]) tail--;
q[++tail]=i;
}
}
for (int i=n-;i>=max(,n-k+);i--) f[n][m]=max(f[n][m],f[i][m]);
if (f[n][m]<) cout<<-;
else cout<<f[n][m];
return ;
}

  小号打的。result:rank 3 rating +311

Codeforces Round #521 Div. 3 玩耍记的更多相关文章

  1. Codeforces Round #521 (Div. 3) E. Thematic Contests(思维)

    Codeforces Round #521 (Div. 3)  E. Thematic Contests 题目传送门 题意: 现在有n个题目,每种题目有自己的类型要举办一次考试,考试的原则是每天只有一 ...

  2. Codeforces Round #394 (Div. 2) 颓废记

    昨天晚上(今天凌晨),又忍不住去打CF.(本蒟弱到只能打Div.2)... 我觉得我可以用一个词概括我这次的CF: 呵呵 刚一开赛,我就codeforces访问失败.. 后来好不容易能上了,两三分钟才 ...

  3. Codeforces Round#500 Div.2 翻车记

    A:签到 #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> # ...

  4. Codeforces Round #521 (Div. 3) D. Cutting Out 【二分+排序】

    任意门:http://codeforces.com/contest/1077/problem/D D. Cutting Out time limit per test 3 seconds memory ...

  5. CodeForces Round #521 (Div.3) E. Thematic Contests

    http://codeforces.com/contest/1077/problem/E output standard output Polycarp has prepared nn competi ...

  6. CodeForces Round #521 (Div.3) D. Cutting Out

    http://codeforces.com/contest/1077/problem/D You are given an array ss consisting of nn integers. Yo ...

  7. Codeforces Round #521 (Div. 3) F1. Pictures with Kittens (easy version)

    F1. Pictures with Kittens (easy version) 题目链接:https://codeforces.com/contest/1077/problem/F1 题意: 给出n ...

  8. Codeforces Round #402 (Div. 2) 阵亡记

    好长时间没有打Codeforces了,今天被ysf拉过去打了一场. lrd也来参(nian)加(ya)比(zhong)赛(sheng) Problem A: 我去,这不SB题吗.. 用桶统计一下每个数 ...

  9. CodeForces Round #521 (Div.3) B. Disturbed People

    http://codeforces.com/contest/1077/problem/B There is a house with nn flats situated on the main str ...

随机推荐

  1. OpenCV 3.2 Viz 3D可视化

    该可视化模块提供了坐标系变化,3D动画等功能 最简单的显示坐标系 viz::Viz3d window("window"); window.showWidget("Coor ...

  2. Ruby 基础教程 1-1

    1.指定编码方式       第一种 在代码文件首行通过 #encoding:GBK的方式     第二种  ruby -E UTF-8 文件名称     第三种  irb  -E UTF-8   2 ...

  3. c# enum 解析

    解析定义的枚举 public enum OrderPaymentStatus { /// <summary> /// 未支付 /// </summary> [Descripti ...

  4. 「日常训练」Equation(HDU-5937)

    题意与分析 时隔一个月之后来补题.说写掉的肯定会写掉. 题意是这样的:给1~9这些数字,每个数字有\(X_i\)个,问总共能凑成多少个不同的等式\(A+B=C\)(\(A,B,C\)均为1位,\(1+ ...

  5. JVM监控远程服务器

    1. 首先配置服务器端,进入服务器tomcat的bin目录下,打开catalina.sh配置文件,xxx为服务器配置路径. # cd /xxx/apache-tomcat-/bin # vim cat ...

  6. NGUI组件整理总结

    一图流: 注意: private void RClickUI(Vector3 newPos) { this.gameObject.SetActive(true); this.transform.loc ...

  7. 零基础自学人工智能,看这些资料就够了(300G资料免费送)

    为什么有今天这篇? 首先,标题不要太相信,哈哈哈. 本公众号之前已经就人工智能学习的路径.学习方法.经典学习视频等做过完整说明.但是鉴于每个人的基础不同,可能需要额外的学习资料进行辅助.特此,向大家免 ...

  8. zabbix 2.2.2 安装部署

    zabbix 2.2.2版本与1.8.3版本安装过程略有不同,下面为实施步骤: 服务端:172.16.1.61 客户端:172.16.1.8 搭建zbbix软件 安装LAMP环境及依赖包 [root@ ...

  9. 十一:Centralized Cache Management in HDFS 集中缓存管理

    集中的HDFS缓存管理,该机制可以让用户缓存特定的hdfs路径,这些块缓存在堆外内存中.namenode指导datanode完成这个工作. Centralized cache management i ...

  10. [leetcode-693-Binary Number with Alternating Bits]

    Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will a ...