题意: 给你一些被占用的时间点,然后有一些询问,每次输出大于等于询问时间的没被占用的最小的那个时间. 思路: 直接把所有用过的时间标记上,然后倒着更新一遍当前最小空余时间,或者用set做,两个都在下面写代码了,水题不解释了,直接看看代码就懂了. #include<stdio.h> #include<string.h> #define N 200000 + 10 int dp[N] ,mark[N]; int main () { int n ,m ,i ,a…
水dp第二天(背包有关) 标签: dp poj_3624 题意:裸的01背包 注意:这种题要注意两个问题,一个是要看清楚数组要开的范围大小,然后考虑需要空间优化吗,还有事用int还是long long 代码: #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int N = 13000; int W[N],D[N]; int dp[N]; int main(…
题意: M*N的grid,每个格上有一个整数. 小明从左上角(1,1)打算走到右下角(M,N). 每次可以向下走一格,或向右走一格,或向右走到当前所在列的倍数的列的位置上.即:若当前位置是(i,j),可以走到(i,k*j) 问取走的最大和是多少. 思路: 水DP...边界的初始化要考虑.(因为有负数). 代码: int n,m; int a[30][1005]; int dp[30][1005]; int main(){ int T; cin>>T; while(T--){ cin>&g…
Another OCD Patient Problem Description Xiaoji is an OCD (obsessive-compulsive disorder) patient. This morning, his children played with plasticene. They broke the plasticene into N pieces, and put them in a line. Each piece has a volume Vi. Since Xi…
Permutation Counting Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1171 Accepted Submission(s): 587 Problem Description Given a permutation a1, a2, … aN of {1, 2, …, N}, we define its E-va…
搬寝室 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Description 搬寝室是很累的,xhd深有体会.时间追述2006年7月9号,那天xhd迫于无奈要从27号楼搬到3号楼,因为10号要封楼了.看着寝室里的n件物品,xhd开始发呆,因为n是一个小于2000的整数,实在是太多了,于是xhd决定随便搬2*k件过去就行了.但还是会很累,因为2*k也不小是一个不…
Chef and Big Soccer Problem code: CHEFSOC2 Tweet ALL SUBMISSIONS All submissions for this problem are available. Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. Chef is a big fan of soccer! He loves soccer so much,…
Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tas…
Matt has N friends. They are playing a game together.Each of Matt's friends has a magic number. In the game, Matt selects some (could be zero) of his friends. If the xor (exclusive-or) sum of the selected friends'magic numbers is no less than M , Mat…
D. Bad Luck Island Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/540/problem/D Description The Bad Luck Island is inhabited by three kinds of species: r rocks, s scissors and p papers. At some moments of time two random i…
水DP dp[i%2][j]=Max(dp[i%2][j-1],dp[1-i%2][j-l[i]]+sum[j]-sum[j-l[i]]); #include "stdio.h" #include "string.h" int Max(int a,int b) { if (a<b) return b; else return a; } int dp[2][1010]; int a[1010],sum[1010],l[22]; int main() { int…