[链接] 我是链接,点我呀:) [题意] 题意 [题解] 从小到大枚举天数. 然后贪心地,从大到小分配a[i]到各个天当中. a[n]分配到第1天,a[n-1]分配到第2天,...然后a[n-x]又分到第一天. 这样能保证优先让大的数字能够无损失地加进去. 从而尽可能快的凑够m天 [代码] #include <bits/stdc++.h> using namespace std; const int N = 100; int n,m; int a[N+10]; vector<int>…
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 枚举最大值和最小值在什么地方. 显然,只要包含最小值的区间,都让他减少. 因为就算那个区间包含最大值,也无所谓,因为不会让答案变小. 但是那些不包含最大值的区间却能让差值变大. 所以没有问题. [代码] #include <bits/stdc++.h> #define ll long long using namespace std; const int N = 300; int n,m; int a[N+10],segl[N+10],…
任意门:http://codeforces.com/contest/1118/problem/D1 D1. Coffee and Coursework (Easy version) time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The only difference between easy and hard versions…
Coffee and Coursework (Easy version) time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The only difference between easy and hard versions is the constraints. Polycarp has to write a coursewor…
https://codeforces.com/contest/1118/problem/D1 能做完的天数最大不超过n,因为假如每天一杯咖啡,每杯咖啡容量大于1 首先对容量进行从大到小的排序, sort(num.rbegin(),num.rend());sort(num.begin(),num.end(),greater<int>());都可以 然后遍历每一天,当第i天的时候,选出i个容量最大的分配到每一天,如果还没写完,继续选择i个最大的,但是由题意容量需要进行衰减,衰减的量为j/i(也就是…
[链接] 我是链接,点我呀:) [题意] 要让前i个数字的和小于等于M. 问你最少要删掉前i-1个数字中的多少个数字,每个询问都是独立的. [题解] ti的范围很小. 所以N*MAX(TI)暴力枚举就行. 如果超过了M的话显然是优先把大的数字删掉. [代码] #include <iostream> using namespace std; const int INF = 100; int n,M; int rest[INF+10]; int main(){ ios::sync_with_std…
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=2000),问满足[数列长度是k && 数列中每一个元素arr[i]在1~n之间 && 数列中元素可以重复]的数列有多少个?结果对10^9+7取余 解题思路:dp[i][j]表示长度是j,最后一位是i的种数 if(kk%i==0) dp[kk][j+1]+=dp[i][j] #inc…
Coffee and Coursework (Hard Version) time limit per test 2.5 seconds memory limit per test 256 megabytes input standard input output standard output The only difference between easy and hard versions is the constraints. Polycarp has to write a course…
[题目链接]:http://codeforces.com/contest/239/problem/B [题意] 给你一个长度为n的字符串,只包括'<">'以及数字0到9; 给你q个区间(n和q都小于等于100) 然后让你在这q个区间里面做一些操作; 有一个指针int,指向当前操作的位置,还有一个方向的int; 表示这个指针它要移动的方向; 每次对一个位置进行操作; 如果该位置是数字; 则把这个数字输出,然后这个数字递减1; 如果数字小于0了,则把它删掉; 然后把指针往方向int的方向…
[题目链接]:http://codeforces.com/contest/816/problem/B [题意] 给你很多个区间[l,r]; 1<=l<=r<=2e5 一个数字如果被k个以上的区间覆盖到; 则称之为特殊数字; 给你q个询问区间; 问你这q个区间里面 每个区间里面有多少个特殊数字; [题解] 对于覆盖的区间l,r add[l]++,sub[r+1]++, 然后顺序枚举 now+=add[i]; now-=sub[i]; 如果now>=k则i是一个特殊数字; 写个前缀和O…