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

Re:5.5秒险过,哈哈哈哈哈哈哈哈哈

Posted by lichuhang at 2019-06-30 21:12:35 on Problem 3688
In Reply To:5.5秒险过,哈哈哈哈哈哈哈哈哈 Posted by:vjubge4 at 2019-06-21 19:00:29
> #include<cstdio>
> #include<cstring>
> #include<algorithm>
> using namespace std;
> int N, S;
> int dp[100000][2];
> int arr[10000];
> 
> int main() {
>     while(true) {
>         scanf("%d %d", &N, &S);
>         if(N == 0 && S == 0) {
>             break;
>         }
>         for(int i = 0; i < N; i ++) {
>             scanf("%d", arr + i);
>         }
>         memset(dp, 0, sizeof(dp));
>         dp[0][0] = true;
>         int ans = 0;
>         for(int j = 0; j < N; j ++) {
>             for(int i = S; i >= 0; i --) {
>                 if(arr[j] <= i) {
>                     if(dp[i - arr[j]][0]) {
>                         dp[i][1] = true;
>                     }
>                     if(dp[i - arr[j]][1]) {
>                         dp[i][0] = true;
>                     }
>                 }
>             }
>         }
>         for(int i = 1; i <= S; i ++) {
>             if(!dp[i][0] && dp[i][1]) {
>                 ans ++;
>             }
>         }
>         printf("%d\n", ans);
>     }
> }

Followed by:

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

Content:

Home Page   Go Back  To top


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