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 |
为什么这么搞就不对呢~ 找了所有测试数据都过了,提交就wa#include <stdio.h> #include <memory.h> struct Pearl { int prize; int nbuy; }; Pearl allPearl[105]; int dp[105]; int nPearl; int main() { int ncase; scanf("%d", &ncase); while(ncase--) { scanf("%d", &nPearl); for( int i = 0; i < nPearl; i++) { scanf("%d%d", &allPearl[i].nbuy, &allPearl[i].prize); } dp[nPearl - 1] = allPearl[nPearl - 1].nbuy; int replace, minPrize = 100000000; int sum = (dp[nPearl - 1] + 10) * allPearl[nPearl-1].prize; for( int i = nPearl - 2; i >= 0; i--) { dp[i] = 0; minPrize = 100000000; for( int j = nPearl - 1; j >= i; j--) { int prize; if(dp[j] == 0) { prize = sum + (allPearl[i].nbuy + 10) * allPearl[j].prize; } else { prize = sum + (allPearl[i].nbuy ) * allPearl[j].prize; } if(prize < minPrize) { minPrize = prize; replace = j; } } dp[replace] += allPearl[i].nbuy; sum = minPrize; } printf("%d\n", sum); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator