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. 关于iOS和Android的安装包更新笔记

    关于iOS和Android的安装包更新问题 1. Android更新apk 1)使用DownloadManager下载 2)使用HttpClient下载 apk的下载不能使用ssl,即不能使用http ...

  2. Linux 7.4配置VSFTP服务器

    vsftpd(very secure ftp daemon,非常安全的FTP守护进程)是一款运行在Linux操作系统上的FTP服务程序,不仅完全开源而且免费,此外,还具有很高的安全性.传输速度,以及支 ...

  3. protected修饰符详解

    protected这个修饰符,各大参考书都会这样说:访问权限为类内,包内和子类,因此在父类中定义的方法和成员变量如果为protected修饰的,是可以在不同包中的子类进行访问的,示例代码如下: pac ...

  4. 读google c++规范笔记

    全局变量在main函数之前初始化原则上禁止拷贝构造函数和赋值函数如果只有数据,没有方法,可以用struct析构函数声明为虚函数尽量避免重载操作符 难以定位的bug 误以为简单的操作存取控制 可以放到声 ...

  5. VS Help Viewer 显示内容为HTML源码的问题

    万恶的IE10 为了学习,安装了一套Windows Server 2012+SQL 2012+VS 2012的环境,整体感觉还不错,只是在使用Help Viewer查看帮助的时候,发现显示内容居然为H ...

  6. 接口测试工具postman(六)添加变量(参数化)

    1.添加全局变量并引用 2.通过设置请求前置配置变量 3.在Tests里面,把响应数据设置为变量 4.添加外部文件,引用外部文件中的变量和数据,此种场景就可以执行多次请求 1)配置文件,txt或者cs ...

  7. python同时遍历两个list

    两个list, 有对应关系,希望同时完成遍历 用迭代器迭代的方法也不是不可以,python提供了更直观的方法: 可以使用zip把两个list打包 , 类似: list1 = [1,2,3,4] lis ...

  8. vmware安装64位系统“此主机支持 Intel VT-x,但 Intel VT-x 处于禁用状态”的问题

    虚拟机使用的是VMware Workstation,并且首次在虚拟机体验64 位系统.在新建好虚拟机,运行时候就出现了VMware Workstation 的提醒:此主机支持 Intel VT-x,但 ...

  9. Beta完结--感想及吐槽

    Beta冲刺结束啦!!! Beta冲刺结束啦!!! Beta冲刺结束啦!!! 这时候每个人的心情肯定都是非常激动的.随着Beta冲刺的结束,折磨了我们一整个学期的软工实践也差不多结束了.(实在是太不容 ...

  10. [git]基本用法1

    一.实验说明 本节实验为 Git 入门第一个实验,可以帮助大家熟悉如何创建和使用 git 仓库. 二.git的初始化 在使用git进行代码管理之前,我们首先要对git进行初始化. 1.Git 配置 使 ...