답안 #1077774

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1077774 2024-08-27T09:04:15 Z LIF Uplifting Excursion (BOI22_vault) C++14
5 / 100
5000 ms 4152 KB
#include<bits/stdc++.h>
using namespace std;
long long int m,dp[300005];
long long int L;
int num[200005];
int val[200005];
int su = 0;
int main()
{
    cin>>m>>L;
    for(int i=1;i<=m*2+1;i++)
    {
        cin>>num[i];
        val[i] = i-m-1;
        su += num[i];
    }
    for(int i=0;i<=300000;i++)dp[i] = -1;
    dp[100000] = 0; //遍移量為1000000
    for (int i=m+1;i<=m*2+1;i++)
    {
        for(int j=1;j<=num[i];j++)
        {
            for(int k=200000;k>=1;k--)
            {
                if(k >= val[i])
                {
                    if(dp[k-val[i]] == -1)continue;
                    if(dp[k] == -1)
                    {
                        dp[k] = dp[k-val[i]] + 1;   
                    }           
                    else dp[k] = max(dp[k-val[i]] + 1,dp[k]);
                }
            }
        }
    }
    for (int i =1;i<=m;i++)
    {
        for(int j=1;j<=num[i];j++)
        {
            for(int k=1;k<=200000;k++)
            {
                if(k - val[i] <= 200000)
                {
                    if(dp[k-val[i]] == -1)continue;
                    if(dp[k] == -1)dp[k] = dp[k-val[i]] + 1;                
                    else dp[k] = max(dp[k-val[i]] + 1,dp[k]);
                }
            }
        }
        
    }


    if(L >= 100000 || L <= 0-100000)
    {
        cout<<"impossible"<<endl;
        return 0;
    }
    else
    {
        if(dp[L+100000] >= 0)cout<<dp[L+100000]<<endl;
        else cout<<"impossible"<<endl;
    }

    








    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 3932 KB Output is correct
2 Correct 4 ms 2764 KB Output is correct
3 Correct 2 ms 2652 KB Output is correct
4 Correct 13 ms 2652 KB Output is correct
5 Correct 438 ms 2772 KB Output is correct
6 Correct 484 ms 2768 KB Output is correct
7 Correct 184 ms 2768 KB Output is correct
8 Correct 469 ms 2772 KB Output is correct
9 Correct 909 ms 2648 KB Output is correct
10 Correct 57 ms 2652 KB Output is correct
11 Correct 18 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 3932 KB Output is correct
2 Correct 4 ms 2764 KB Output is correct
3 Correct 2 ms 2652 KB Output is correct
4 Correct 13 ms 2652 KB Output is correct
5 Correct 438 ms 2772 KB Output is correct
6 Correct 484 ms 2768 KB Output is correct
7 Correct 184 ms 2768 KB Output is correct
8 Correct 469 ms 2772 KB Output is correct
9 Correct 909 ms 2648 KB Output is correct
10 Correct 57 ms 2652 KB Output is correct
11 Correct 18 ms 2652 KB Output is correct
12 Correct 4 ms 2652 KB Output is correct
13 Correct 2 ms 2652 KB Output is correct
14 Correct 3 ms 2652 KB Output is correct
15 Correct 15 ms 2652 KB Output is correct
16 Correct 465 ms 2648 KB Output is correct
17 Correct 542 ms 3932 KB Output is correct
18 Correct 208 ms 2652 KB Output is correct
19 Correct 495 ms 4152 KB Output is correct
20 Correct 979 ms 2772 KB Output is correct
21 Correct 28 ms 3932 KB Output is correct
22 Correct 21 ms 2772 KB Output is correct
23 Correct 2114 ms 2768 KB Output is correct
24 Incorrect 1991 ms 4144 KB Output isn't correct
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 2648 KB Output is correct
2 Execution timed out 5049 ms 2652 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 2648 KB Output is correct
2 Execution timed out 5049 ms 2652 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 2648 KB Output is correct
2 Execution timed out 5049 ms 2652 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 3932 KB Output is correct
2 Correct 4 ms 2764 KB Output is correct
3 Correct 2 ms 2652 KB Output is correct
4 Correct 13 ms 2652 KB Output is correct
5 Correct 438 ms 2772 KB Output is correct
6 Correct 484 ms 2768 KB Output is correct
7 Correct 184 ms 2768 KB Output is correct
8 Correct 469 ms 2772 KB Output is correct
9 Correct 909 ms 2648 KB Output is correct
10 Correct 57 ms 2652 KB Output is correct
11 Correct 18 ms 2652 KB Output is correct
12 Correct 14 ms 2648 KB Output is correct
13 Execution timed out 5049 ms 2652 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 2648 KB Output is correct
2 Execution timed out 5049 ms 2652 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 3932 KB Output is correct
2 Correct 4 ms 2764 KB Output is correct
3 Correct 2 ms 2652 KB Output is correct
4 Correct 13 ms 2652 KB Output is correct
5 Correct 438 ms 2772 KB Output is correct
6 Correct 484 ms 2768 KB Output is correct
7 Correct 184 ms 2768 KB Output is correct
8 Correct 469 ms 2772 KB Output is correct
9 Correct 909 ms 2648 KB Output is correct
10 Correct 57 ms 2652 KB Output is correct
11 Correct 18 ms 2652 KB Output is correct
12 Correct 4 ms 2652 KB Output is correct
13 Correct 2 ms 2652 KB Output is correct
14 Correct 3 ms 2652 KB Output is correct
15 Correct 15 ms 2652 KB Output is correct
16 Correct 465 ms 2648 KB Output is correct
17 Correct 542 ms 3932 KB Output is correct
18 Correct 208 ms 2652 KB Output is correct
19 Correct 495 ms 4152 KB Output is correct
20 Correct 979 ms 2772 KB Output is correct
21 Correct 28 ms 3932 KB Output is correct
22 Correct 21 ms 2772 KB Output is correct
23 Correct 2114 ms 2768 KB Output is correct
24 Incorrect 1991 ms 4144 KB Output isn't correct
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 2648 KB Output is correct
2 Execution timed out 5049 ms 2652 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 3932 KB Output is correct
2 Correct 4 ms 2764 KB Output is correct
3 Correct 2 ms 2652 KB Output is correct
4 Correct 13 ms 2652 KB Output is correct
5 Correct 438 ms 2772 KB Output is correct
6 Correct 484 ms 2768 KB Output is correct
7 Correct 184 ms 2768 KB Output is correct
8 Correct 469 ms 2772 KB Output is correct
9 Correct 909 ms 2648 KB Output is correct
10 Correct 57 ms 2652 KB Output is correct
11 Correct 18 ms 2652 KB Output is correct
12 Correct 4 ms 2652 KB Output is correct
13 Correct 2 ms 2652 KB Output is correct
14 Correct 3 ms 2652 KB Output is correct
15 Correct 15 ms 2652 KB Output is correct
16 Correct 465 ms 2648 KB Output is correct
17 Correct 542 ms 3932 KB Output is correct
18 Correct 208 ms 2652 KB Output is correct
19 Correct 495 ms 4152 KB Output is correct
20 Correct 979 ms 2772 KB Output is correct
21 Correct 28 ms 3932 KB Output is correct
22 Correct 21 ms 2772 KB Output is correct
23 Correct 2114 ms 2768 KB Output is correct
24 Incorrect 1991 ms 4144 KB Output isn't correct
25 Halted 0 ms 0 KB -