A.(c1=0&&c3>0)||(c1!=c4)

 #include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
typedef long long ll;
using namespace std; int c1,c2,c3,c4; int main(){
freopen("a.in","r",stdin);
freopen("a.out","w",stdout);
scanf("%d%d%d%d",&c1,&c2,&c3,&c4);
if ((!c1 && c3) || c1!=c4) puts(""); else puts("");
return ;
}

A

B.每次免费的显然应该是第n-q+1大的那个。

 #include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
typedef long long ll;
using namespace std; const int N=;
int n,m,x,a[N];
ll sm; int main(){
scanf("%d",&n);
rep(i,,n) scanf("%d",&a[i]),sm+=a[i];
sort(a+,a+n+); scanf("%d",&m);
rep(i,,m) scanf("%d",&x),cout<<sm-a[n-x+]<<endl;
return ;
}

B

C.正难则反,先计算所有区间的并集sm,再计算最少要使多长区间不被覆盖ans,答案即sm-ans。

考虑枚举区间i,j,那么不涂这两个区间会使b[i]+b[j]+c[i][j]的区间不被覆盖。其中b[i]为只能由第i个区间覆盖的区间长度,c[i][j]为只能被i,j两个区间覆盖的区间长度。先O(nq)预处理出b,c,再O(q^2)计算答案即可。

 #include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
typedef long long ll;
using namespace std; const int N=;
int n,m,l,r,sm,ans,x[N],y[N],b[N],mp[N][N]; int main(){
scanf("%d%d",&n,&m); ans=n+;
rep(i,,m){
scanf("%d%d",&l,&r);
rep(j,l,r){
if (y[j]) x[j]=y[j]=-;
if (x[j] && !y[j]) y[j]=i;
if (!x[j]) x[j]=i;
}
}
rep(i,,n){
if (x[i]) sm++;
if (x[i]> && !y[i]) b[x[i]]++;
if (x[i]> && y[i]>) mp[x[i]][y[i]]++,mp[y[i]][x[i]]++;
}
rep(i,,m) rep(j,,m) if (i!=j) ans=min(ans,b[i]+b[j]+mp[i][j]);
printf("%d\n",sm-ans);
return ;
}

C

D.二分答案,每次找到最先降到0以下的那个同学充电。

 #include<queue>
#include<cstdio>
#include<iostream>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
typedef long long ll;
using namespace std; const int N=;
int n,k;
ll mx,a[N],b[N];
struct P{ ll a,b,r; };
bool operator <(const P &a,const P &b){ return a.r>b.r; }
priority_queue<P>Q; bool chk(ll mid){
while (!Q.empty()) Q.pop();
rep(i,,n) Q.push((P){a[i],b[i],a[i]/b[i]});
rep(t,,k){
P x=Q.top(); Q.pop();
if (x.a/x.b+<t) return ;
if (x.a/x.b+>=k) return ;
Q.push((P){x.a+mid,x.b,(x.a+mid)/x.b});
}
return ;
} int main(){
ios::sync_with_stdio();
cin>>n>>k;
rep(i,,n) cin>>a[i];
rep(i,,n) cin>>b[i],mx=max(mx,b[i]);
ll L=,R=(k-)*mx+;
while (L<R){
ll mid=(L+R)>>;
if (chk(mid)) R=mid; else L=mid+;
}
if (L>=(k-)*mx+) puts("-1"); else cout<<L<<endl;
return ;
}

D

Educational Codeforces Round 61 (Div.2)的更多相关文章

  1. Educational Codeforces Round 61

    Educational Codeforces Round 61 今早刚刚说我适合打pikmike出的EDU 然后我就挂了 A 不管 B 不管 C 这道题到快结束了才调出来 大概就是\(n^2\)枚举不 ...

  2. Educational Codeforces Round 84 (Div. 2)

    Educational Codeforces Round 84 (Div. 2) 读题读题读题+脑筋急转弯 = =. A. Sum of Odd Integers 奇奇为奇,奇偶为偶,所以n,k奇偶性 ...

  3. Educational Codeforces Round 61 (Rated for Div. 2) D,F题解

    D. Stressful Training 题目链接:https://codeforces.com/contest/1132/problem/D 题意: 有n台电脑,每台电脑都有初始电量ai,也有一个 ...

  4. Educational Codeforces Round 61 (Rated for Div. 2) E 多重背包优化

    https://codeforces.com/contest/1132/problem/E 题意 有8种物品,重量是1~8,每种数量是\(cnt[i]\)(1e16),问容量为W(1e18)的背包最多 ...

  5. Educational Codeforces Round 61 (Rated for Div. 2)-C. Painting the Fence 前缀和优化

    题意就是给出多个区间,要求去掉两个区间,使得剩下的区间覆盖范围最大. 当然比赛的时候还是没能做出来,不得不佩服大佬的各种姿势. 当时我想的是用线段树维护区间和,然后用单点判0,维护区间间断个数.然后打 ...

  6. Educational Codeforces Round 61 (Rated for Div. 2)

    A. Regular Bracket Sequence 题意:给出四种括号的数量 ((  )) ()  )( 问是否可以组成合法的序列(只能排序不能插在另外一个的中间) 思路: 条件一:一个或 n个) ...

  7. Educational Codeforces Round 61 (Rated for Div. 2) E. Knapsack

    非常经典的dp题,因为1至8的最大公约数是840,任何一个数的和中840的倍数都是可以放在一起算的, 所以我只需要统计840*8的值(每个数字(1-8)的sum%840的总和),剩下都是840的倍数 ...

  8. Educational Codeforces Round 61 (Rated for Div. 2) G(线段树,单调栈)

    #include<bits/stdc++.h>using namespace std;int st[1000007];int top;int s[1000007],t[1000007];i ...

  9. Educational Codeforces Round 61 (Rated for Div. 2)F(区间DP,思维,枚举)

    #include<bits/stdc++.h>typedef long long ll;const int inf=0x3f3f3f3f;using namespace std;char ...

随机推荐

  1. NTC3950-10K温度传感器

    一.计算公式 补充: B=3950 R=10K T2=25度 查RT表,25度对应的是10K 电路: 热敏电阻与上拉电阻R813分压,获取温度与Vo电压的关系,在根据Vo折算出与MCU ADC的数值. ...

  2. Mybatis-Generator开发教程

    转载:https://blog.csdn.net/qqyb2000/article/details/80031559 MyBatis是一个支持普通SQL查询,存储过程和高级映射的优秀持久层框架.MyB ...

  3. IntelliJ IDEA悬停鼠标显示方法详细信息

    1.如果View -> Toolbar勾选情况下, 直接点击按钮打开设置, 或是直接点击File -> Settings(或是快捷键)打开设置窗口. 2.搜索栏中输入Show quick ...

  4. Thread.currentThread与this的区别

    在看多线程的时候,看到这个知识点,感觉需要验证一下. 一:线程自启动 1.程序 package com.jun.it.thread; public class MyThread extends Thr ...

  5. Apache Rewrite 静态配置

    1.mod_rewrite 简介和配置 Rewirte主要的功能就是实现URL的跳转和隐藏真实地址,基于Perl语言的正则表达式规范.平时帮助我们实现拟静态,拟目录,域名跳转,防止盗链等如一个普通访问 ...

  6. 单例模式以及Python实现

    单例模式以及Python实现 单例模式 单例模式就是确保一个类只有一个实例.当你希望整个系统中,某个类只有一个实例时,单例模式就派上了用场.比如,某个服务器的配置信息存在在一个文件中,客户端通过App ...

  7. Microsoft VBScript 运行时错误 错误 800a005e 无效使用 Null: Replace

    查看数据库   表的字段里面是否有空的字段. where 字段名 is null

  8. opencv3.4.6 cmake

    Selecting Windows SDK version to target Windows 10.0.16299. Found PythonInterp: N:/Anaconda3/install ...

  9. test20190904

  10. 在tomcat下context.xml中配置各种数据库连接池

    作者:郑文亮 Tomcat6的服务器配置文件放在 ${tomcat6}/conf 目录底下.我们可以在这里找到 server.xml 和 context.xml.当然,还有其他一些资源文件.但是在在本 ...