Codeforces Round #538 (Div. 2)
作者:互联网
目录
- A.Got Any Grapes?
- B.Yet Another Array Partitioning Task
- C.Trailing Loves (or L'oeufs?)
- D.Flood Fill(区间DP)
- E.Arithmetic Progression(交互 二分 随机化)
- F.Please, another Queries on Array?(线段树 欧拉函数)
貌似最近平均难度最低的一场div2了...
但我没有把握住机会TAT
D题没往DP想 写模拟自闭了40多分钟...才发现是个傻逼区间DP
再多二十分钟就能调出F的傻逼错误了...
A.Got Any Grapes?
puts
的返回值原来是0。。刚开始写的return !puts("NO");
在样例上RE了一次= =
#include <set>
#include <map>
#include <cstdio>
#include <cctype>
#include <vector>
#include <cstring>
#include <algorithm>
#define pc putchar
#define gc() getchar()
typedef long long LL;
inline int read()
{
int now=0,f=1;register char c=gc();
for(;!isdigit(c);c=='-'&&(f=-1),c=gc());
for(;isdigit(c);now=now*10+c-48,c=gc());
return now*f;
}
int main()
{
int x=read(),y=read(),z=read(),a=read(),b=read(),c=read();
if(a<x) return puts("NO"),0;
a-=x;
if(a+b<y) return puts("NO"),0;
int tot=a+b+c-y-z;
if(tot<0) return puts("NO"),0;
return puts("YES"),0;
return 0;
}
B.Yet Another Array Partitioning Task
因为可以每隔\(m\)个分一段,所以选出最大的\(m*k\)个数,每隔\(m\)个分一段就行了。
#include <set>
#include <map>
#include <cstdio>
#include <cctype>
#include <vector>
#include <cstring>
#include <algorithm>
#define pc putchar
#define gc() getchar()
typedef long long LL;
const int N=2e5+5;
struct Node
{
int v,p;
bool operator <(const Node &x)const
{
return v==x.v?p<x.p:v>x.v;
}
}A[N];
inline int read()
{
int now=0,f=1;register char c=gc();
for(;!isdigit(c);c=='-'&&(f=-1),c=gc());
for(;isdigit(c);now=now*10+c-48,c=gc());
return now*f;
}
int main()
{
static int Ans[N];
static bool vis[N];
int n=read(),m=read(),K=read();
for(int i=1; i<=n; ++i) A[i]=(Node){read(),i};
std::sort(A+1,A+1+n);
LL sum=0;
for(int i=1; i<=K*m; ++i) vis[A[i].p]=1, sum+=A[i].v;
int cnt=0;
for(int i=1,t=0; i<=n; ++i)
if(vis[i] && ++t==m)
t=0, Ans[++cnt]=i;
printf("%I64d\n",sum);
for(int i=1; i<cnt; ++i) printf("%d ",Ans[i]);
return 0;
}
C.Trailing Loves (or L'oeufs?)
D.Flood Fill(区间DP)
E.Arithmetic Progression(交互 二分 随机化)
F.Please, another Queries on Array?(线段树 欧拉函数)
标签:now,int,Codeforces,long,read,gc,Div,include,538 来源: https://www.cnblogs.com/SovietPower/p/10361309.html