Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
反向dp,附代妈#include <iostream> #include <stdio.h> using namespace std; int kyList[2500][2500]; int main() { int t; scanf("%d", &t); for(int i = 0; i < t; i++){ int mxT = 0, n; scanf("%d", &n); if(n==0) { printf("0\n"); continue; } int start[2500], end[2500], span[2500]; int kyNo[2500] = {0}; for(int j = 0; j < n; j++){ scanf("%d%d%d", &span[j], &start[j], &end[j]); if(end[j] > mxT) mxT = end[j]; for(int t = start[j]; t <= end[j]-span[j]; t++){ kyList[t][kyNo[t]] = j; kyNo[t]++; } } int wt[2500]; for(int j = 0; j <= mxT; j++){ wt[j] = 2147483647; } wt[mxT] = 0; for(int j = mxT-1; j>=0; j--){ if(kyNo[j] == 0) wt[j] = wt[j+1]; else{ for(int k = 0; k < kyNo[j]; k++){ int wn = kyList[j][k]; int temp = span[wn] + wt[j+span[wn]]; if(temp < wt[j]) wt[j] = temp; } } } printf("%d\n", wt[0]); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator