Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
 User ID: Password:
Register

## 贴个c++代码

Posted by a280920481 at 2019-02-03 12:03:20 on Problem 1260
```#include <iostream>
using namespace std;

const int INF = 0x70123456;
const int MAX_N = 105;

int need[MAX_N], price[MAX_N];

int dp[MAX_N];

int _min(int a, int b);

int main()
{
int T, c;

scanf("%d", &T);

while (T--)
{
scanf("%d", &c);

for (int i = 1; i <= c; i++)
{
scanf("%d%d", need + i, price + i);
dp[i] = INF;
}

for (int i = 1; i <= c; i++)
{
int s = 10;
for (int j = i; j; j--)
{
s += need[j];
dp[i] = _min(dp[i], dp[j - 1] + s * price[i]);
}
}

printf("%d\n", dp[c]);
}
return 0;
}

int _min(int a, int b)
{
return a < b ? a : b;
}
```

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator