Educational Codeforces Round 61 (Div.2)
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)的更多相关文章
- Educational Codeforces Round 61
Educational Codeforces Round 61 今早刚刚说我适合打pikmike出的EDU 然后我就挂了 A 不管 B 不管 C 这道题到快结束了才调出来 大概就是\(n^2\)枚举不 ...
- Educational Codeforces Round 84 (Div. 2)
Educational Codeforces Round 84 (Div. 2) 读题读题读题+脑筋急转弯 = =. A. Sum of Odd Integers 奇奇为奇,奇偶为偶,所以n,k奇偶性 ...
- Educational Codeforces Round 61 (Rated for Div. 2) D,F题解
D. Stressful Training 题目链接:https://codeforces.com/contest/1132/problem/D 题意: 有n台电脑,每台电脑都有初始电量ai,也有一个 ...
- Educational Codeforces Round 61 (Rated for Div. 2) E 多重背包优化
https://codeforces.com/contest/1132/problem/E 题意 有8种物品,重量是1~8,每种数量是\(cnt[i]\)(1e16),问容量为W(1e18)的背包最多 ...
- Educational Codeforces Round 61 (Rated for Div. 2)-C. Painting the Fence 前缀和优化
题意就是给出多个区间,要求去掉两个区间,使得剩下的区间覆盖范围最大. 当然比赛的时候还是没能做出来,不得不佩服大佬的各种姿势. 当时我想的是用线段树维护区间和,然后用单点判0,维护区间间断个数.然后打 ...
- Educational Codeforces Round 61 (Rated for Div. 2)
A. Regular Bracket Sequence 题意:给出四种括号的数量 (( )) () )( 问是否可以组成合法的序列(只能排序不能插在另外一个的中间) 思路: 条件一:一个或 n个) ...
- Educational Codeforces Round 61 (Rated for Div. 2) E. Knapsack
非常经典的dp题,因为1至8的最大公约数是840,任何一个数的和中840的倍数都是可以放在一起算的, 所以我只需要统计840*8的值(每个数字(1-8)的sum%840的总和),剩下都是840的倍数 ...
- 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 ...
- 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 ...
随机推荐
- CMU Database Systems - Concurrency Control Theory
并发控制是数据库理论里面最难的课题之一 并发控制首先了解一下事务,transaction 定义如下, 其实transaction关键是,要满足ACID属性, 左边的正式的定义,由于的intuitive ...
- visual studio python快捷键
打开交互式窗口: alt + i 智能提示: ctrl + j, or alt + ->
- hadoop 参数调优重点参数
yarn的参数调优,必调参数 28>.yarn.nodemanager.resource.memory-mb 默认为8192.每个节点可分配多少物理内存给YARN使用,考虑到节点上还 可能有其 ...
- OpenGL ES: (4) EGL API详解 (转)
上一节我们初步学习了 OpenGL ES.EGL.GLSL 的相关概念,了解了它们的功能,以及它们之间的关联.我们知道了 EGL 是绘制 API(比如 OpenGL ES)与 底层平台窗口系统之间的接 ...
- 海思uboot启动流程详细分析(转)
海思uboot启动流程详细分析(一) 海思uboot启动流程详细分析(二) 海思uboot启动流程详细分析(三)
- tomcat的AJP(定向包协议)协议
由于tomcat的html和图片解析功能相对其他服务器如apche等较弱,所以,一般都是集成起来使用,只有jsp和servlet服务交由tomcat处理,而tomcat和其他服务器的集成,就是通过aj ...
- 对有序特征进行离散化(继承Spark的机器学习Estimator类)
采用信息增益或基尼指数寻找最优离散化点 package org.apache.spark.ml.feature import org.apache.spark.sql.SparkSession imp ...
- Python3基础 九九乘法表
Python : 3.7.3 OS : Ubuntu 18.04.2 LTS IDE : pycharm-community-2019.1.3 ...
- Spring的@ExceptionHandler和@ControllerAdvice统一处理异常
之前敲代码的时候,避免不了各种try..catch, 如果业务复杂一点, 就会发现全都是try…catch try{ ..........}catch(Exception1 e){ ......... ...
- EXCEL导入配置开发
1.登录infor 企业级 选择 配置 EXCEL导入配置 2.新增配置(设置模板名.说明.存储过程名称.应用仓库) 后保存 3.将excel模板放到服务器 路径:/opt/infor/sce/wil ...