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 ...
随机推荐
- 3阶马尔可夫链 自然语言处理python
一.简介: 把每三个三个单词作为一个整体进行训练. 举一个例子: input: my dream is that I can be an engineer, so I desi ...
- 知识点:Mysql 索引原理完全手册(1)
知识点:Mysql 索引原理完全手册(1) 知识点:Mysql 索引原理完全手册(2) 知识点:Mysql 索引优化实战(3) 知识点:Mysql 数据库索引优化实战(4) Mysql-索引原理完全手 ...
- Oracle “CONNECT BY” (层级递归查询)
Oracle “CONNECT BY”是层次查询子句,一般用于树状或者层次结果集的查询.其语法是: ? 1 2 [ START WITH condition ] CONNECT BY [ NOCYCL ...
- axure8.0激活
Licensee:米 业成 (STUDENT)Key:nFmqBBvEqdvbiUjy8NZiyWiRSg3yO+PtZ8c9wdwxWse4WprphvSu9sohAdpNnJK5
- day73 Django框架之URL
Django框架之url路由层一 Django数据库的一对多与多对多表的建立 一对多 publish_id的建立:publish=models.ForeignKey(to='Publish', to ...
- 题 FatMouse‘Trade
FatMouse准备了M磅的猫食,准备与守卫仓库的猫交易,这些猫包含他最喜欢的食物,JavaBean. 仓库有N个房间.第i间房间包含J [I]磅的JavaBeans,并且需要F [i]磅的猫粮.Fa ...
- 灰熊:在这6个信息流和DSP平台投放后,我总结了这些血泪经验!
笔者有幸参与公司的一款重度游戏的推广,推广以来市面上主流的信息流和DSP 平台都投过一番,今天就零零碎碎地讲讲各个平台的特点以及用户质量. 需要提前说明的是,文章的观点仅限于各个平台的 iOS 流量, ...
- spring boot 入门(一)
转自构建微服务:Spring boot 入门篇 什么是spring boot Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程. ...
- 深入理解Java虚拟机读书笔记3----类文件结构
三 类文件结构 1 Java虚拟机的两种中立特性 · 平台无关性 · 语言无关性 实现平台无关性和语言无关性的基础是虚拟机和字节码存储格式(Class文件). 2 Clas ...
- DO,DTO和VO的使用
DO,DTO和VO的使用 DO:对应数据库表结构 VO:一般用于前端展示使用 DTO:用于数据传递.(接口入参和接口返回值都可以) 以ssm框架为例: controller层: public List ...