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 |
为什么用DM还超时呢?rt code: #include "iostream" #include "string.h" #include "stdio.h" using namespace std; main() { char c[10003]={'\0'}; int p[1000]={0}; int i; char o; p[105]=1; p[118]=5; p[120]=10; p[108]=50; p[99]=100; p[100]=500; p[109]=1000; int t; int l=0; int n; int po, pi; while (gets(c)) { long h[10001][3]={0}; l=0; n=strlen(c); pi=0; po=1; for (i=0; i<n ;i++) { if (p[c[i]]) { l++; h[l][1]=h[l][0]=p[c[i]]; } } int j, k; long tot=0; long y=0; for (i=po+1;i<=l;i++) { for (j=po;j<i;j++) if ((h[i][0]<h[j][0])&&(h[i][0]+h[j][1]>h[i][1])) { h[i][1]=h[i][0]+h[j][1]; } } cout<<h[l][1]<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator