답안 #579683

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
579683 2022-06-19T15:50:50 Z wdjpng Uplifting Excursion (BOI22_vault) C++17
0 / 100
398 ms 3988 KB
#include <bits/stdc++.h>

#define int long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >=0; i--)

using namespace std;

signed main()
{
    int m,l;
    cin>>m>>l;
    int maxl=(m)*(m+1)/2*50; //TODO change to 100
    if(l>maxl) {cout<<"impossible\n"; exit(0);}
    vector<int>dp(2*maxl+100000, -1);
    dp[maxl]=0;
 
    for(int cl = -m; cl <= m; cl++)
    {
        int a;
        cin>>a;
        rep(whatever,a)
        {
            if(cl>0)
            {
                per(i,2*maxl+1)
                {
                    if(i-cl<0||i-cl>=dp.size()||dp[i-cl]==-1) continue;
                    dp[i]=max(dp[i], dp[i-cl]+1);
                }
            } else
            rep(i,2*maxl+1) 
            {
                if(i-cl<0||i-cl>=dp.size()||dp[i-cl]==-1) continue;
                dp[i]=max(dp[i], dp[i-cl]+1);
            }
        }
    }
    assert(l+maxl<dp.size());
    if(dp[l+maxl]>0) cout<<dp[l+maxl]<<'\n';
    else cout<<"impossible\n";
}

Compilation message

vault.cpp: In function 'int main()':
vault.cpp:28:36: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |                     if(i-cl<0||i-cl>=dp.size()||dp[i-cl]==-1) continue;
      |                                ~~~~^~~~~~~~~~~
vault.cpp:34:32: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |                 if(i-cl<0||i-cl>=dp.size()||dp[i-cl]==-1) continue;
      |                            ~~~~^~~~~~~~~~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from vault.cpp:1:
vault.cpp:39:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     assert(l+maxl<dp.size());
      |            ~~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 2 ms 1108 KB Output is correct
5 Runtime error 398 ms 3988 KB Execution killed with signal 6
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 2 ms 1108 KB Output is correct
5 Runtime error 398 ms 3988 KB Execution killed with signal 6
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 2 ms 1108 KB Output is correct
5 Runtime error 398 ms 3988 KB Execution killed with signal 6
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 2 ms 1108 KB Output is correct
5 Runtime error 398 ms 3988 KB Execution killed with signal 6
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 2 ms 1108 KB Output is correct
5 Runtime error 398 ms 3988 KB Execution killed with signal 6
6 Halted 0 ms 0 KB -