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. Python监控rabbitmq的代码

    author:headsen chen date: 2019-07-26  17:22:24 notice: 个人原创 import requests, json, time, datetime fr ...

  2. git---分支的合并

    git使用分支也可进行多人协作开发. 一.创建分支 git branch zhaozilong 创建一个 zhaozilong 的分支 二.查看所有的分支 git branch -a :查看当前的所有 ...

  3. 【转载】 tensorflow中 tf.train.slice_input_producer 和 tf.train.batch 函数

    原文地址: https://blog.csdn.net/dcrmg/article/details/79776876 ----------------------------------------- ...

  4. linux记录-安装elk记录(参考博文)

    什么是ELK? 通俗来讲,ELK是由Elasticsearch.Logstash.Kibana .filebeat三个开源软件的组成的一个组合体,这三个软件当中,每个软件用于完成不同的功能,ELK 又 ...

  5. 使用Commons math做数值计算

    使用Commons math做数值计算 觉得有用的话,欢迎一起讨论相互学习~Follow Me 最近使用jmetal做多目标的时候,想用一些简单的方法求最大值最小值方差和协方差矩阵,但是原生代码真的是 ...

  6. 【Leetcode_easy】914. X of a Kind in a Deck of Cards

    problem 914. X of a Kind in a Deck of Cards 题意:每个数字对应的数目可以均分为多组含有K个相同数目该数字的数组. 思路:使用 map 结构记录数组中每个元素 ...

  7. 【Leetcode_easy】872. Leaf-Similar Trees

    problem 872. Leaf-Similar Trees 参考 1. Leetcode_easy_872. Leaf-Similar Trees; 完

  8. html 图标和文字一行对齐

    原图: 效果图: 备注:vertical-align:middle <div> <p class="time tl-size12" style="pad ...

  9. MultiDesk远程桌面连接

    MultiDesk 是一个选项卡(TAB标签)方式的远程桌面连接 (Terminal Services Client),可以管理组远程桌面连接,更改连接端口. 功能特性 绿色软件,只有一个很小的可执行 ...

  10. skynet sproto 问题

    刚碰到一个小细节,纠结了半个小时 sproto的协议,request 和{ 必须有空格