题目链接:http://codeforces.com/problemset/problem/760/B 题意:n个床位,m个枕头,第k个位置最多有多少个枕头,其中相邻之间的差<=1; 第k个位置最大,那么两边只能是-1,-2,-3下走. 二分查找. #include <bits/stdc++.h> using namespace std; long long n,m,k; int Slove(long long mid) { ; if(k>=mid) { sum+=(+mid)*m…
二分,判断条件就是最小情况(设当前k位取x)比剩余值(m-x)要小.(貌似又做麻烦了2333) #include<bits/stdc++.h> #define LL long long #define N 100005 using namespace std; inline int ra() { ,f=; char ch=getchar(); ; ch=getchar();} +ch-'; ch=getchar();} return x*f; } int n,m,k; bool check(L…
B. Frodo and pillows time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Ea…
http://codeforces.com/problemset/problem/760/B 题意:有n张床m个枕头,每张床可以有多个枕头,但是相邻的床的枕头数相差不能超过1,问第k张床最多能拥有的枕头数是多少.每张床至少有一个枕头. 思路:因为每张床至少需要一个枕头,所以先将m减掉n之后来考虑剩余枕头如何分配. 我们考虑一个最优的情况,假设有5张床,9个枕头,k为3的时候,那么这样分配:1 2 3 2 1,这样其实就如同阶梯一样,要让第k个最高,然后向两边递减. 我们可以二分答案,使用等差数列…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and…
C - Preparing for the Contest Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 377B Description Soon there will be held the world's largest programming contest, but the testing system sti…
题目链接:Codeforces 484B Maximum Value 题目大意:给定一个序列,找到连个数ai和aj,ai%aj尽量大,而且ai≥aj 解题思路:类似于素数筛选法的方式,每次枚举aj,然后枚举k,每次用二分找到小于k∗aj而且最大的ai,维护答案,过程中加了一些剪枝. #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxn =…
题目链接:https://codeforces.com/problemset/problem/607/A 题意: 有 $n$ 个塔排成一行,第 $i$ 个激光塔的位置为 $a_i$,伤害范围是 $b_i$,激活第 $i$ 个塔后,所有在这个塔左侧且距离小于等于 $b_i$ 的塔都会被摧毁,但该塔本身不会被摧毁. 现在会从右向左依次激活每个塔,如果一个塔被摧毁则无法被激活. 现在要在这 $n$ 个激光塔的右边再放一个塔,该塔的位置和威力是任意的.现在从这个新加入的塔开始从右到左依次激活每个塔,求最…
You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters. Suitability of string s is calculated by following metric: Any two letters can be swapped positions, these operations can be performed arbi…
D. Leaving Auction time limit per test: 2 seconds memory limit per test:256 megabytes input:standard input output:standard output There are n people taking part in auction today. The rules of auction are classical. There were n bids made, though it's…