답안 #579720

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
579720 2022-06-19T16:42:48 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)
        {
            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);
                }
            }
        }
        if(cl==0) continue;
        a=in[m-cl];
        cl=-cl;
        rep(whatever,a)
        {
            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);
            }
        }
    }
    
    if(l+maxl<dp.size()&&dp[l+maxl]>0) cout<<dp[l+maxl]<<'\n';
    else cout<<"impossible\n";
}

Compilation message

vault.cpp:8: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    8 | #pragma optimize("sse,sse2,sse3,sse4,avx,avx2")
      | 
vault.cpp: In function 'int main()':
vault.cpp:33: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]
   33 |                     if(i-cl<0||i-cl>=dp.size()||dp[i-cl]==-1) continue;
      |                                ~~~~^~~~~~~~~~~
vault.cpp:45: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]
   45 |                 if(i-cl<0||i-cl>=dp.size()||dp[i-cl]==-1) continue;
      |                            ~~~~^~~~~~~~~~~
vault.cpp:51: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]
   51 |     if(l+maxl<dp.size()&&dp[l+maxl]>0) cout<<dp[l+maxl]<<'\n';
      |        ~~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 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 -