Codeforces Canda Cup 2016

A、B:模拟

C、构造下就行了

D、题意:n个参加ACM的队(n<=300000),每个队都有自己的初始气球数和重量,规定如果气球数>重量,那么此队就会飞起来,淘汰出局,你现在是第一组,你可以给其他组气球,问你最高能排名多少,你的排名是气球数严格大于你气球数的队伍数+1。

   分析:贪心的想法,将那些气球数大于你的队伍放在优先队列里维护wi-ti的最小值,优先淘汰wi-ti小的队伍,给他气球的同时,你也会气球减少,也就可能有其他你后面的队伍比你高,这些队要新加入优先队列。

      具体的操作是将所有队伍按照气球多少从小到大排序,从后往前扫,扫到当前气球数<你的气球数为止,将后面的这些加入优先队列。取出最小的淘汰他,再将指针往前移动,看看是否能有新的进入优先队列,直至扫完并且优先队列出队完毕。在这个过程中,优先队列的长度一直都在变化,其中长度的最小值+1就是你的最好排名了。

时间: 2024-08-26 17:22:06

Codeforces Canda Cup 2016的相关文章

codeforces 8VC Venture Cup 2016 - Elimination Round C. Lieges of Legendre

C. Lieges of Legendre 题意:给n,m表示有n个为2的倍数,m个为3的倍数:问这n+m个数不重复时的最大值 最小为多少? 数据:(0 ≤ n, m ≤ 1 000 000, n + m > 0) ps:很水的题,主要是策略: 思路:由于里面每隔6就会重复一次,不好直接模拟,并且模拟的效率很低,那就二分吧!二分即上界为2单独的最大倍数与3单独时的最大倍数之和,下界为前面二者的max;之后利用判断是否mid/2 >= n && mid/3 >= m &am

Codeforces#348DIV2/VK CUP 2016

昨天第一次开大小号打cf,发现原来小号提交之后大号在此提交同样的代码会被skipped掉,然后之后提交的代码都不记分,昨天a,b,c都是水题 A 题意:问一个物品最多能被分成多少份,分成的连续两份不能相同 分析:直接1,2这样份,所以除以3乘2,在对3取模 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <string> 5 #include <vect

Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) B

#include<stdio.h> #include<algorithm> #include<vector> #include<string.h> using namespace std; int main() { int n,m,i; while(scanf("%d%d",&n,&m)!=EOF) { vector<int> da,xi; int a,b; int maxa=1,minb=n; for(i=1

Codeforces Round #348 (VK Cup 2016 Round 2, Div. 1 Edition) C. Little Artem and Random Variable 数学

C. Little Artem and Random Variable Little Artyom decided to study probability theory. He found a book with a lot of nice exercises and now wants you to help him with one of them. Consider two dices. When thrown each dice shows some integer from 1 to

Codeforces 8VC Venture Cup 2016 - Elimination Round F. Group Projects 差分DP*****

F. Group Projects There are n students in a class working on group projects. The students will divide into groups (some students may be in groups alone), work on their independent pieces, and then discuss the results together. It takes the i-th stude

Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition)

A. Bear and Game 题意:一个体育节目,它可能在某一分钟是很有趣的,其他时间都是很无聊的,如果持续十五分钟都很无聊的话那么Bear就会关掉电视,问什么时候会关掉电视. 题解:用第i个有趣的时间减去第i-1个有趣的时间,如果差值大于十五分钟那就输出第i个有趣的时间+15.注意第一个有趣的时间要为0,最后一个为90. 代码: 1 /*A*/ 2 #include<cstdio> 3 using namespace std; 4 5 const int maxn=95; 6 7 int

Codeforces Round #348(VK Cup 2016 - Round 2)

A - Little Artem and Presents (div2) 1 2 1 2这样加就可以了 #include <bits/stdc++.h> typedef long long ll; const int N = 1e5 + 5; int main() { int n; scanf ("%d", &n); int ans = n / 3 * 2; if (n % 3) { ans++; } printf ("%d\n", ans);

Codeforces VK Cup 2015 Wild Card Round 1 (AB)

比赛链接:http://codeforces.com/contest/522 A. Reposts time limit per test:1 second memory limit per test:256 megabytes One day Polycarp published a funny picture in a social network making a poll about the color of his handle. Many of his friends started

codeforces Good bye 2016 E 线段树维护dp区间合并

题目大意:给你一个字符串,范围为'0'~'9',定义一个ugly的串,即串中的子串不能有2016,但是一定要有2017,问,最少删除多少个字符,使得串中符合ugly串? 思路:定义dp(i, j),其中i=5,j=5,因为只需要删除2016当中其中一个即可,所以一共所需要删除的字符和需要的字符为20176,因此i和j只要5就够了. 然后转移就是dp(i,i) = 0, 如果说区间大小为1的话,那么如果是2017中的一个,那么就是dp(pos, pos+1) = 0, dp(pos,pos) =