Codeforces_813
A.统计总时间,从总时间开始找第一个能提交的点。
#include<bits/stdc++.h>
using namespace std; int n,m,a[],ok[] = {}; int main()
{
ios::sync_with_stdio();
cin >> n;
int sum = ;
for(int i = ;i <= n;i++) cin >> a[i],sum += a[i];
cin >> m;
for(int i = ;i <= m;i++)
{
int x,y;
cin >> x >>y;
for(int j = x;j <= y;j++) ok[j] = ;
}
for(int i = sum;i <= ;i++)
{
if(ok[i])
{
cout << i << endl;
return ;
}
}
cout << - << endl;
return ;
}
B.把每个unlucky值都算出来,再算最长段。
#include<bits/stdc++.h>
using namespace std; long long x,y,l,r,a[],b[]; int main()
{
ios::sync_with_stdio();
cin >> x >> y >> l >> r;
int cnt1 = ,cnt2 = ;
a[++cnt1] = ;
b[++cnt2] = ;
while(a[cnt1] <= r/x)
{
a[cnt1+] = a[cnt1]*x;
cnt1++;
}
while(b[cnt2] <= r/y)
{
b[cnt2+] = b[cnt2]*y;
cnt2++;
}
set<long long> s;
for(int i = ;i <=cnt1;i++)
{
if(a[i] > r) continue;
for(int j = ;j <= cnt2;j++)
{
if(b[j] > r) continue;
if(a[i]+b[j] < l) continue;
if(a[i]+b[j] > r) continue;
s.insert(a[i]+b[j]);
}
}
s.insert(l-);
s.insert(r+);
long long ans = ;
for(auto it = ++s.begin();it != s.end();it++)
{
long long xx = *it;
it--;
long long yy = *it;
it++;
ans = max(ans,xx-yy-);
}
cout << ans << endl;
return ;
}
C.分两种情况,Bob一直往下跑到叶子节点或者先往上跑,再往下跑到更深的叶子节点。
#include<bits/stdc++.h>
using namespace std; int n,x,a[] = {},maxx[],ok[] = {};
int ans;
vector<int> v[]; void dfs1(int now,int pre)
{
maxx[now] = a[now];
for(int i = ;i < v[now].size();i++)
{
int t = v[now][i];
if(t == pre) continue;
a[t] = a[now]+;
dfs1(t,now);
if(ok[t]) ok[now] = ;
maxx[now] = max(maxx[now],maxx[t]);
}
} int main()
{
ios::sync_with_stdio();
cin >> n >> x;
ok[x] = ;
for(int i = ;i < n;i++)
{
int x,y;
cin >> x >> y;
v[x].push_back(y);
v[y].push_back(x);
}
dfs1(,-);
ans = maxx[x];
for(int i = ;i <= n;i++)
{
if(ok[i])
{
if(a[x]-a[i] < a[i]) ans = max(ans,maxx[i]);
}
}
cout << ans* << endl;
return ;
}
Codeforces_813的更多相关文章
随机推荐
- 1038 统计同成绩学生 (20 分)C语言
题目描述 本题要求读入N名学生的成绩,将获得某一给定分数的学生人数输出. 输入描述: 输入在第1行给出不超过105的正整数N,即学生总人数.随后1行给出N名学生的百分制整数成绩,中间以空格分隔.最后1 ...
- React Native 性能优化指南【全网最全,值得收藏】
2020 年谈 React Native,在日新月异的前端圈,可能算比较另类了.文章动笔之前我也犹豫过,但是想到写技术文章又不是赶时髦,啥新潮写啥,所以还是动笔写了这篇 React Native 性能 ...
- MongoDB 上手开发实践(入门上手开发这一篇就够了)
前言 MongoDB是一个介于 关系数据库 和非关系数据库之间的产品,是非关系数据库当中功能最丰富,最像关系数据库的.它支持的数据结构非常松散,是类似 json 的 bson 格式,因此可以存储比较复 ...
- 学以致用,react学习前奏准备阶段
ReactJS:支持React开发,提供JSX代码提示,高亮显示,ReactJS官方介绍 1.cdm→ componentDidMount: fn() { ... } cdm 2.cdup→ ...
- 升级添加到现有iOS Xcode项目的Flutter
如果你在2019年8月之前将Flutter添加到现有iOS项目,本文值得你一看. 在2019年7月30日,合并合并请求flutter / flutter#36793之前Flutter 1.8.4-pr ...
- Educational Codeforces Round 80 D E
A了三题,rk1000左右应该可以上分啦,开
- 解决el-tree lazy懒加载时,连续勾选前两个子节点后第二次进入默认选中时,将父节点也勾选的问题
在用到el-tree的懒加载和默认勾选功能时,若第一次勾选前几个连续节点,第二次进入默认勾选时,由于el-tree子节点尚未完全加载(只加载出来前几个),默认勾选已经开始(已加载出来的子节点被默认勾选 ...
- svn或git 提交文件排除
也可以参考 https://blog.csdn.net/chenmintong/article/details/79725324 乌龟git 过滤掉忽略文件(首先右键 某文件 删除并添加到忽略列表 ...
- Oracle GoldenGate for DB2
--Enable logdb2 update db cfg using LOGARCHMETH1 DISK:/home/db2inst1/arclogs--Rebootdb2 terminatedb2 ...
- [LOJ#3022][网络流]「CQOI2017」老 C 的方块
题目传送门 定义有特殊边相邻的格子颜色为黑,否则为白 可以看出,题目给出的限制条件的本质是如果两个小方块所在的格子 \(x\) 和 \(y\) 为两个相邻的黑格,那么 \(x\) 和 \(y\) 之间 ...