제출 #653603

#제출 시각아이디문제언어결과실행 시간메모리
653603AdamGSUplifting Excursion (BOI22_vault)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; typedef long long ll; const int maxn = 100; int M; ll L; vector<int> pos(maxn+5), neg(maxn+5); void solve(){ cin >> M >> L; for(int i = 1; i <= M; i++) cin >> neg[M-i+1]; ll ans; cin >> ans; for(int i = 1; i <= M; i++) cin >> pos[i]; int maxn3 = (maxn*maxn+1)/2*maxn; vector<ll> knapsack1(maxn3+5, -1e18), knapsack2(maxn3+5, -1e18); knapsack1[0] = knapsack2[0] = 0; for(int i = 1; i <= M; i++){ int bigof = max(pos[i], neg[i]); for(int make = maxn3 - i; make >= 0; make--){ for(int use=0; use < pos[i]; ++use) if(kanpsack1[make]<knapsack1[make-use*i]) knapsack1[make]=knapsack1[make-use*i]; for(int use=0; use<neg[i]; ++use) if(knapsack2[make]<knapsack2[make-use*i]) knapsack2[make]=knapsack2[make-use*i]; } } ll add = -1e18; for(int i = 0; i <= maxn3; i++){ ll need = L-i; if(need > 0){ continue; }else if(need == 0){ add = max(add, knapsack1[i]); }else if(-need >= maxn3 || knapsack2[-need] < 0 || knapsack1[i] < 0){ continue; }else{ add = max(add, knapsack1[i] + knapsack2[-need]); } } if(add == -1e18){ cout << "impossible\n"; }else{ cout << ans+add; } } int main(){ ios::sync_with_stdio(false); cin.tie(0); int tt = 1; // cin >> tt; while(tt--){ solve(); } }

컴파일 시 표준 에러 (stderr) 메시지

vault.cpp: In function 'void solve()':
vault.cpp:28:46: error: 'kanpsack1' was not declared in this scope; did you mean 'knapsack1'?
   28 |       for(int use=0; use < pos[i]; ++use) if(kanpsack1[make]<knapsack1[make-use*i])
      |                                              ^~~~~~~~~
      |                                              knapsack1
vault.cpp:26:9: warning: unused variable 'bigof' [-Wunused-variable]
   26 |     int bigof = max(pos[i], neg[i]);
      |         ^~~~~