D. Gadgets for dollars and pounds time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Nura wants to buy k gadgets. She has only s burles for that. She can buy each gadget for dollars or for po…
D. Gadgets for dollars and pounds 题目连接: http://www.codeforces.com/contest/609/problem/C Description Nura wants to buy k gadgets. She has only s burles for that. She can buy each gadget for dollars or for pounds. So each gadget is selling only for som…
D. Gadgets for dollars and pounds time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Nura wants to buy k gadgets. She has only s burles for that. She can buy each gadget for dollars or for po…
对于这题笔者无解,只有手抄一份正解过来了: 基本思想就是 : 二分答案,对于第x天,计算它最少的花费f(x),<=s就是可行的,这是一个单调的函数,所以可以二分. 对于f(x)的计算,我用了nlog(n)的算法,遍历m个商品,用c[i]乘以前x天里,第t[i]种货币的最便宜的价格,存放到一个数组里,之后排序,计算前k个的和就是f(x) 前x天里,第t[i]种货币的最便宜的价格是通过预处理得到的,很容易的计算一下前缀最小值就行了. 贴代码吧: #include <iostream> #in…
题目链接: D. Gadgets for dollars and pounds time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Nura wants to buy k gadgets. She has only s burles for that. She can buy each gadget for dollars or…
D. Professor GukiZ and Two Arrays 题目连接: http://www.codeforces.com/contest/620/problem/D Description Professor GukiZ has two arrays of integers, a and b. Professor wants to make the sum of the elements in the array a sa as close as possible to the sum…
题目:http://codeforces.com/contest/1156/problem/E 题意:给你1-n  n个数,然后求有多少个区间[l,r] 满足    a[l]+a[r]=max([l,r]) 思路:首先我们去枚举区间肯定不现实,我们只能取把能用的区间去用,我们可以想下每个数当最大值的时候所做的贡献 我们既然要保证这个数为区间里的最大值,我们就要从两边扩展,找到左右边界能扩展在哪里,这里你直接去枚举肯定不行 这里我们使用了线段树二分去枚举左右区间最远能走到哪里,然后很暴力的去枚举短…
#include<bits/stdc++.h>using namespace std;typedef long long ll;int n,k;ll a[200007],b[200007],s[200007];ll ans;int check(ll val){ memset(s,0,sizeof(s)); int num=k; for(int i=1;i<=n;i++){  if(!b[i])   continue;  s[min(a[i]/b[i]+1,1ll*(k+1))]++;//…
题意:给出一个字符串s, 可以从左往右拿走s的字符, 至少要到s的第几个位置才能拼成t 思路:用二维数组记录前缀,然后二分即可. #include<bits/stdc++.h> using namespace std; #define inf 5000000 #define N 210050 ]; ]; string s; string str; int n; bool slove(int id) { ; i<; i++) ) return false; return true; } i…
这题1<<M为255,可以logN二分答案后,N*M扫一遍表把N行数据转化为一个小于等于255的数字,再255^2检验答案(比扫一遍表复杂度低),复杂度约为N*M*logN #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ][]; ][]; int n,m; int ans,ans2; ],pre[]; int zhuangya(int x,int y){ ;i<=m;++i)…