Educational Codeforces Round 43 (Rated for Div. 2)

https://codeforces.com/contest/976

A

 #include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define IT set<ll>::iterator
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 200005
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll>pll;
typedef pair<ll,int> pli;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long MOD=;
const double oula=0.57721566490153286060651209;
using namespace std; int main(){
std::ios::sync_with_stdio(false);
int n;
string str;
cin>>n>>str;
if(str=="") cout<<<<endl;
else {
int co=;
for(int i=;i<str.length();i++){
if(str[i]=='') co++;
}
cout<<;
for(int i=;i<co;i++){
cout<<;
}
cout<<endl;
}
}

B

 #include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define IT set<ll>::iterator
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 200005
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll>pll;
typedef pair<ll,int> pli;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long MOD=;
const double oula=0.57721566490153286060651209;
using namespace std; int main(){
std::ios::sync_with_stdio(false);
ll n,m,k;
cin>>n>>m>>k;
if (k<n) {
cout<<k+<<" "<<<<endl;
return ;
}
k-=n-;
if (k==) {
cout<<n<<" "<<;
return ;
}
k-=;
ll l=k/(m-);
k%=(m-);
if((n-l)%==) cout<<n-l<<" "<< k+<<endl;
else cout<<n-l<<" "<<m-k<<endl;
}

C

题意:是否存在一条线段是否包含另一条线段,有的话就输出其中一个解

思路:sort排序下即可

 #include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define IT set<ll>::iterator
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 200005
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll>pll;
typedef pair<ll,int> pli;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long MOD=;
const double oula=0.57721566490153286060651209;
using namespace std; vector<pair<int,pair<int,int> > >ve; bool cmp(pair<int,pair<int,int> > a,pair<int,pair<int,int> > b){
if(a.second.first==b.second.first) return a.second.second>b.second.second;
return a.second.first<b.second.first;
} int main(){
std::ios::sync_with_stdio(false);
int n;
cin>>n;
int x,y;
for(int i=;i<=n;i++){
cin>>x>>y;
ve.pb({i,{x,y}});
}
sort(ve.begin(),ve.end(),cmp);
int L=ve[].second.first,R=ve[].second.second,pos=ve[].first;
int flag=;
for(int i=;i<ve.size();i++){
if(L<=ve[i].second.first&&R>=ve[i].second.second){
cout<<ve[i].first<<" "<<pos<<endl;
return ;
}
L=ve[i].second.first,R=ve[i].second.second,pos=ve[i].first;
}
if(!flag){
cout<<-<<" "<<-<<endl;
}
}

D

题意:

给你一个长度为 n 的正整数序列 d1​,d2​,⋯,dn​ (d1​<d2​<⋯<dn​ )。要求你构造一个满足以下条件的无向图:

  1. 有恰好 dn​+1 个点。
  2. 没有自环。
  3. 没有重边。
  4. 总边数不超过 10^6。
  5. 它的度数集合等于 dd 。

点从 1标号至 dn​+1 。

图的度数序列是一个长度与图的点数相同的数组 a,其中 ai​ 是第 i 个顶点的度数(与其相邻的顶点数)。图的度数集合是度数序列排序后去重的结果。

思路:把前d[1]个点向所有点连接一条边后,就会出现有d[1]个度为d[n]的点,剩下的点度都为d[1],然后我们可以继续构造(d[2]-d[1],d[3]-d[1],d[4]-d[1]....d[n-1]-d[1])的点,不断缩小子问题

 #include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define IT set<ll>::iterator
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 200005
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll>pll;
typedef pair<ll,int> pli;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long MOD=;
const double oula=0.57721566490153286060651209;
using namespace std; vector<pii>ve;
int d[]; int main(){
std::ios::sync_with_stdio(false);
int n;
cin>>n;
for(int i=;i<=n;i++) cin>>d[i];
int L=,R=n;
int co=;
while(L<=R){
for(int i=d[L-]+;i<=d[L];i++){
for(int j=i+;j<=d[R]+;j++){
ve.pb({i,j});
co++;
}
}
L++;
R--;
}
cout<<co<<endl;
for(int i=;i<ve.size();i++){
cout<<ve[i].first<<" "<<ve[i].second<<endl;
}
}

E

题意:你有n个小兵,每个小兵都有血条和攻击力,你可以使用a种1操作,b种2操作,是小兵们的攻击力之和最大。1操作:是一个小兵当前血量翻倍 。2操作:把一个小兵当前的血量值赋值给攻击力。

思路:容易想到,把a操作的都给集中给一个小兵是最好的,所以我们可以先按血量-攻击力的差值从大到小排序,然后不断分情况枚举a给谁最好。

 #include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define IT set<ll>::iterator
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 200005
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll>pll;
typedef pair<ll,int> pli;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long MOD=;
const double oula=0.57721566490153286060651209;
using namespace std; ll n,a,b;
vector<pll>ve; bool cmp(pll a,pll b){
return a.first-a.second>b.first-b.second;
} int main(){
std::ios::sync_with_stdio(false);
ll x,y;
cin>>n>>a>>b;
b=min(b,n);
for(int i=;i<=n;i++){
cin>>x>>y;
ve.pb({x,y});
}
sort(ve.begin(),ve.end(),cmp);
ll sum=;
for(int i=;i<b;i++){
sum+=max(ve[i].first,ve[i].second);
}
for(int i=b;i<n;i++){
sum+=ve[i].second;
}
ll ans=sum;
for(int i=;i<b;i++){
ans=max(ans,sum-max(ve[i].first,ve[i].second)+(ve[i].first<<a));
}
sum-=max(ve[b-].first,ve[b-].second)-ve[b-].second;
if(b){
for(int i=b;i<n;i++){
ans=max(ans,sum-ve[i].second+(ve[i].first<<a));
}
}
cout<<ans<<endl;
}

F

待补

Educational Codeforces Round 43 (Rated for Div. 2)的更多相关文章

  1. Educational Codeforces Round 43 (Rated for Div. 2) ABCDE

    A. Minimum Binary Number time limit per test 1 second memory limit per test 256 megabytes input stan ...

  2. Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship

    Problem   Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...

  3. Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)

    Problem   Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...

  4. Educational Codeforces Round 35 (Rated for Div. 2)

    Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...

  5. Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings

    Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings 题目连接: http://cod ...

  6. Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes

    Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes 题目连接: http://code ...

  7. Educational Codeforces Round 63 (Rated for Div. 2) 题解

    Educational Codeforces Round 63 (Rated for Div. 2)题解 题目链接 A. Reverse a Substring 给出一个字符串,现在可以对这个字符串进 ...

  8. Educational Codeforces Round 39 (Rated for Div. 2) G

    Educational Codeforces Round 39 (Rated for Div. 2) G 题意: 给一个序列\(a_i(1 <= a_i <= 10^{9}),2 < ...

  9. Educational Codeforces Round 48 (Rated for Div. 2) CD题解

    Educational Codeforces Round 48 (Rated for Div. 2) C. Vasya And The Mushrooms 题目链接:https://codeforce ...

随机推荐

  1. 使用uiautomator2进行webview页面的测试

    1.开发开启webview debug模式 2.使用VirtualXposed框架进行webview测试,详细见https://testerhome.com/topics/16156 下载,安装Vir ...

  2. Mysql8.0导入数据时出错

    在Windows操作系统下,使用命令行将已经创建好的txt文件导入到mysql的pet表中. 出现ERROR 1148 (42000): The used command is not allowed ...

  3. js判断是否安装某个android app,没有安装下载该应用(websocket通信,监听窗口失去焦点事件)

    现在经常有写场景需要提示用户下载app, 但是如果用户已经安装,我们希望是直接打开app. 实际上,js是没有判断app是否已经安装的方法的,我们只能曲线救国. 首先,我们需要有call起app的sc ...

  4. 打包时,node内存溢出问题解决方法

    在使用npm run build打包时,遇到node内存溢出问题. 网上查找到的决绝方案.解决方案一: 安装increase-memory-limit插件,扩大node的内存限制 但是,这个解决方案在 ...

  5. springboot+VUE(二)

    入element-ui cnpm install element-ui -S 执行后,会下载element-ui的包到本地,同时会将配置加入到package.json的依赖块中. 通过命令行可以将最新 ...

  6. iframe高度宽度自适应

    iframe { width: 100%; height: 100%; border: none; position: inherit; } 网上全是js方法,而且略显臃肿,故找到了一个css方法,宽 ...

  7. Teradata简介

    Teradata是受欢迎的关系数据库管理系统之一. 它主要适用于构建大规模数据仓库应用程序.Teradata通过并行性的概念实现了这一点. 它是由Teradata公司开发的. 无限并行化-  Tera ...

  8. javascript基础知识笔记-自用

    笔记内容根据个人基础知识不足不明白之处做的记录.主要看的:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript 1.变量,变量的名字又叫标识符 ...

  9. linux查看指定时间段的日志

    不需要tail命令,直接 grep '2018-04-22 12:3[2-9]' tesl.log: 这就是查询指定文件的2018-04-22 12点32分到39分的日志

  10. java使用Filter过滤器对Response返回值进行修改

    转:java使用Filter过滤器对Response返回值进行修改 练习时只做了对request 的处理,这里记录一下,filter 对 response的处理. 原文地址:java使用Filter过 ...