답안 #579731

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
579731 2022-06-19T17:00:46 Z wdjpng Uplifting Excursion (BOI22_vault) C++17
0 / 100
1 ms 340 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--)
    
// #pragma GCC optimize("O3")
// #pragma optimize("sse,sse2,sse3,sse4,avx,avx2")
using namespace std;
    
signed main()
{
    int m,l;
    cin>>m>>l;
    int maxl=(m)*(m+1)/2*100; //TODO change to 100
    if(l>maxl) {cout<<"impossible\n"; exit(0);}
    vector<int>dp(2*maxl, -1);
    dp[maxl]=0;
    
    vector<int>in(2*m+1);
    rep(i,2*m+1) cin>>in[i];

    for(int cll = m; cll >=0; cll--)
    {
        int cl = cll;
        int a = in[m+cl];
        rep(whatever,a)
        {
                for(int j = min(cl*(cl+1)/2*100,maxl); j >= -min(cl*(cl+1)/2*100,maxl); j--)
                {
                    int i = j+maxl;
                    if(i-cl<0||i-cl>=dp.size()||dp[i-cl]==-1) continue;
                    dp[i]=max(dp[i], dp[i-cl]+1);
                
            }
        }
        if(cl==0) continue;
        a=in[m-cl];
        int oldcl;
        cl=-cl;
        rep(whatever,a)
        {
            for(int j = -min(oldcl*(oldcl+1)/2*100, maxl); j <= min(oldcl*(oldcl+1)/2*100,maxl); j++)
            {
                int i = j+maxl;
                if(i-cl<0||i-cl>=dp.size()||dp[i-cl]==-1) continue;
                dp[i]=max(dp[i], dp[i-cl]+1);
            }
        }
    }



    if(l+maxl<dp.size()&&dp[l+maxl]>0) cout<<dp[l+maxl]<<'\n';
    else cout<<"impossible\n";
}

Compilation message

vault.cpp: In function 'int main()':
vault.cpp:32: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]
   32 |                     if(i-cl<0||i-cl>=dp.size()||dp[i-cl]==-1) continue;
      |                                ~~~~^~~~~~~~~~~
vault.cpp:46: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]
   46 |                 if(i-cl<0||i-cl>=dp.size()||dp[i-cl]==-1) continue;
      |                            ~~~~^~~~~~~~~~~
vault.cpp:54:14: 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]
   54 |     if(l+maxl<dp.size()&&dp[l+maxl]>0) cout<<dp[l+maxl]<<'\n';
      |        ~~~~~~^~~~~~~~~~
vault.cpp:39:13: warning: 'oldcl' may be used uninitialized in this function [-Wmaybe-uninitialized]
   39 |         int oldcl;
      |             ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -