-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaoj0246.cpp
48 lines (45 loc) · 1.04 KB
/
aoj0246.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;
const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int,int> P;
struct edge{int to,cost;};
int n;
int m[100];
int main(){
while(cin >> n, n){
for(int i=0;i<n;i++){
scanf("%d",&m[i]);
}
//i番目のまんじゅうまで使って、余ってる重さの合計がj
int dp[101][10];
memset(dp, 0, sizeof(dp));
for(int i=1;i<=n;i++){
dp[i][j]
for(int j=0;j<10;j++){
dp[i][j]
if(j-m[i-1]<0){
dp[i][j] = max(dp[i-1][j], dp[i-1][10+j-m[i-1]]+1);
}else{
dp[i][j] = max(dp[i-1][j], dp[i-1][j-m[i-1]]);
}
}
}
}
return 0;
}