답안 #600728

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
600728 2022-07-21T07:30:12 Z isaachew Uplifting Excursion (BOI22_vault) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
/*
 Lift
 
 ST3-6 are split up into half-subtasks
 
 ST2.5-5.5: simple DP?
 
 5000ms time limit;
 
 20p with brute force O((n/2)^5)
 2:56 pm
 
 ST1/2: plain brute force (O(M*(sum(a_l)^2)) = O(n^5))
 
 */
std::vector<int> uplifts;
int main(){
    int m;
    long long l;
    std::cin>>m>>l;
    int maxv=0;
    for(int i=-m;i<=m;i++){
        int x;
        std::cin>>x;
        uplifts.push_back(x);
        maxv=std::max(x,maxv);
    }
    if(m*m*maxv*maxv<=100000000){
        int tmv=m*(m+1)/2*maxv;//really only half of the max
        std::vector<int> values1(tmv,-1000000000);//positive
        std::vector<int> values2(tmv,-1000000000);//negative
        values1[0]=0;
        values2[0]=0;
        for(int k=1;k<=m;k++){
            for(int x=0;x<uplifts[m+k];x++){
                    values1[y+k]=std::max(values1[y]+1,values1[y+k]);
                }
            }
        }
        for(int k=1;k<=m;k++){
            for(int x=0;x<uplifts[m-k];x++){
                for(int y=tmv-1-k;y>=0;y--){
                    values2[y+k]=std::max(values2[y]+1,values2[y+k]);
                }
            }
        }
        int totalmax=0;
        for(int i=0;i<tmv&&i-l<tmv;i++){
            if(i-l<0)continue;
            totalmax=std::max(totalmax,values1[i]+values2[i-l]);
        }
        std::cout<<totalmax+uplifts[m]<<'\n';
    }
}

Compilation message

vault.cpp: In function 'int main()':
vault.cpp:37:29: error: 'y' was not declared in this scope
   37 |                     values1[y+k]=std::max(values1[y]+1,values1[y+k]);
      |                             ^
vault.cpp:43:27: error: 'tmv' was not declared in this scope; did you mean 'tm'?
   43 |                 for(int y=tmv-1-k;y>=0;y--){
      |                           ^~~
      |                           tm
vault.cpp:44:21: error: 'values2' was not declared in this scope
   44 |                     values2[y+k]=std::max(values2[y]+1,values2[y+k]);
      |                     ^~~~~~~
vault.cpp:49:23: error: 'tmv' was not declared in this scope; did you mean 'tm'?
   49 |         for(int i=0;i<tmv&&i-l<tmv;i++){
      |                       ^~~
      |                       tm
vault.cpp:51:40: error: 'values1' was not declared in this scope
   51 |             totalmax=std::max(totalmax,values1[i]+values2[i-l]);
      |                                        ^~~~~~~
vault.cpp:51:51: error: 'values2' was not declared in this scope
   51 |             totalmax=std::max(totalmax,values1[i]+values2[i-l]);
      |                                                   ^~~~~~~
vault.cpp: At global scope:
vault.cpp:55:1: error: expected declaration before '}' token
   55 | }
      | ^