Educational Codeforces Round 43 (Rated for Div. 2)
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 )。要求你构造一个满足以下条件的无向图:
- 有恰好 dn+1 个点。
- 没有自环。
- 没有重边。
- 总边数不超过 10^6。
- 它的度数集合等于 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)的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- Educational Codeforces Round 35 (Rated for Div. 2)
Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...
- 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 ...
- 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 ...
- Educational Codeforces Round 63 (Rated for Div. 2) 题解
Educational Codeforces Round 63 (Rated for Div. 2)题解 题目链接 A. Reverse a Substring 给出一个字符串,现在可以对这个字符串进 ...
- 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 < ...
- Educational Codeforces Round 48 (Rated for Div. 2) CD题解
Educational Codeforces Round 48 (Rated for Div. 2) C. Vasya And The Mushrooms 题目链接:https://codeforce ...
随机推荐
- c# 简单方便的连接oracle方式
通过nuget安装ManagedDataAccess (自动生成的config里面的配置都可以删掉) winform程序,拖出一个datagridview和button using Oracle.Ma ...
- 关于eclipse创建web工程没有生成webapp文件夹的解决方案
先看工程建立的是不是配置的打成War包,然后按下图所示
- 用自己的话简要阐述struts2的执行流程
Struts 2框架本身大致可以分为3个部分:核心控制器FilterDispatcher.业务控制器Action和用户实现的企业业务逻辑组件.核心控制器FilterDispatcher是Struts ...
- Python threading(多线程)
threading模块在较低级别thread模块之上构建更高级别的线程接口. 一.threading模块定义了以下函数和对象: threading.active_count() 等同于threadin ...
- Springboot+ mybatis+ mysql配置@Slf4j
spring: datasource: driver-class-name: com.mysql.cj.jdbc.Driver # 驱动 name: testDB # 配置名,可以随便写 userna ...
- loadrunner代理录制脚本
1.打开loadrunner录制脚本选项: 2.start recording弹窗选择options: 3.设置loadrunner端口,可自定义:后面的浏览器设置代理需要用到此处设置的端口号: 4 ...
- shiro初识
shiro 可以做认证.授权.加密.会话管理.与web集成.缓存. 在本文中,主要使用认证和授权这两个功能. 在shiro框架中,有些很重要的概念: Subject 很多人把它理解为当前用户,这 ...
- MapReduce时mapping内存不足
17/11/07 16:53:50 INFO mapreduce.Job: Job job_1510042506570_0007 failed with state KILLED due to: MA ...
- python 配置文件解析模块 configparser
import ConfigParser //实例化cf = ConfigPraser.ConfigPraser()cf.read("配置文件") //获取所有sections.也就 ...
- azkaban使用--依赖dependencies作业
1.创建作业 [root@localhost azkaban_job]# ls one.job two.job [root@localhost azkaban_job]# cat one.job ty ...