Codeforces Round #398 (Div. 2) A,B,C,D】的更多相关文章

Codeforces Round #398 (Div. 2) A.Snacktower 模拟 我和官方题解的命名神相似...$has$ #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> using namespace std; typedef long long ll; ; inline int read()…
A. Snacktower 题目连接: http://codeforces.com/contest/767/problem/A Description According to an old legeng, a long time ago Ankh-Morpork residents did something wrong to miss Fortune, and she cursed them. She said that at some time n snacks of distinct s…
题目链接:http://codeforces.com/contest/767/problem/C 题解:类似于提着一串葡萄,用剪刀剪两条藤,葡萄分成了三串.问怎样剪才能使三串葡萄的质量相等. 首先要做的就是统计葡萄的总质量tot.之后就是找到两子串质量为(tot/3)的葡萄(如果除不尽,则必定找不到),那么剩下的就是dfs搜索了. 我一开始的做法是先建一棵记录子树质量和的树,然后再从上往下dfs,如果找到了,就把它剪掉.后来发现被剪掉的那一串可能就含有两串质量为(tot/3)的葡萄(这里质量 可…
这场cf时间特别好,周六下午,于是就打了打(谁叫我永远1800上不去div1) 比以前div2的题目更均衡了,没有太简单和太难的...好像B题难度高了很多,然后卡了很多人. 然后我最后做了四题,E题感觉不会太难就是切不下来,还好前面几题A的快居然混了个RANK6,然后+204,终于上到紫名了...... ---------我是分割线君 A.Snacktower 有一个1到n的全排列,按顺序每一秒会到达一个数,你要把它们从n到1叠起来,如果能叠,你就马上叠. 比如n=3到达顺序312 ,那么你第一…
A. Snacktower time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output According to an old legeng, a long time ago Ankh-Morpork residents did something wrong to miss Fortune, and she cursed them. S…
A. Snacktower time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output According to an old legeng, a long time ago Ankh-Morpork residents did something wrong to miss Fortune, and she cursed them. S…
B. The Queue time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Finally! Vasya have come of age and that means he can finally get a passport! To do it, he needs to visit the passport office, b…
设sum是所有灯泡的亮度之和 有两种情况: 一种是存在结点U和V,U是V的祖先,并且U的子树权值和为sum/3*2,且U不是根,且V的子树权值和为sum/3. 另一种是存在结点U和V,他们之间没有祖先关系,两者的子树权值和都是sum/3.(已经出栈的结点和当前访问的结点之间,必然没有祖先关系) 两次dfs解决. #include<cstdio> #include<algorithm> #include<cstdlib> using namespace std; int…
卡题意……妈的智障 一个人的服务时间完整包含在整个工作时间以内. 显然,如果有空档的时间,并且能再下班之前完结,那么直接输出即可,显然取最左侧的空档最优. 如果没有的话,就要考虑“挤掉”某个人,就是在某个人之前1分钟到达,这样显然比较优. 就这些情况都考虑上就得了. #include<cstdio> using namespace std; typedef long long ll; ll ts,tf,t,a[100010],b[100010],wait=10000000000000ll,an…
题意不复述. 用个bool数组记录一下,如果某一天,当前剩下的最大的出现了的话,就输出一段. #include<cstdio> using namespace std; int n; bool vis[100010]; int main() { // freopen("a.in","r",stdin); scanf("%d",&n); int x; int now=n; for(int i=1;i<=n;++i) { s…