답안 #603153

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
603153 2022-07-23T16:06:48 Z DanerZein Uplifting Excursion (BOI22_vault) C++14
5 / 100
5000 ms 8020 KB
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX_L=505000;
const int MAX_N=110;
vector<int> mapo(MAX_L);
vector<int> mane(MAX_L);
void maxObjects(vector<int> &x, vector<int> &dp,const int MAX_L){
  for(int i=0;i<x.size();i++){
    if(x[i]==0) continue;
    vector<int> spa;
    for(int j=0;j<=MAX_L;j++){
      if(dp[j]!=0) spa.push_back(j);
    }
    for(int j=0;j<spa.size();j++){
      for(int k=1;k<=x[i];k++){
	dp[spa[j]+(i+1)*k]=max(dp[spa[j]+(i+1)*k],dp[spa[j]]+k);
      }
    }
    for(int k=1;k<=x[i];k++){
      dp[(i+1)*k]=max(dp[(i+1)*k],k);
    }
  }
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  int n; ll L; cin>>n>>L;
  vector<int> neg;
  for(int i=0;i<n;i++){
    int a; cin>>a;
    neg.push_back(a);
  }
  reverse(neg.begin(),neg.end());
  int c0; cin>>c0;
  vector<int> pos;
  for(int i=0;i<n;i++){
    int a; cin>>a;
    pos.push_back(a);
  }
  //const int MAX_L=(n*(n+1)/2)*n;
  if(abs(L)>MAX_L){
    cout<<"impossible\n";
    return 0;
  }
  mapo[0]=mane[0]=c0;
  maxObjects(neg,mane,MAX_L);
  maxObjects(pos,mapo,MAX_L);
  int ans;
  if(L>0) ans=mapo[L];
  else ans=mane[abs(L)];
  for(int i=0;i<=MAX_L;i++){
    int d=i-L;
    if(d>=0 && mane[d]!=0 && mapo[i]!=0){
      ans=max(ans,mapo[i]+mane[d]-c0);
    }
  }
  if(ans==0) cout<<"impossible\n";
  else
    cout<<ans<<endl;
}

Compilation message

vault.cpp: In function 'void maxObjects(std::vector<int>&, std::vector<int>&, int)':
vault.cpp:10:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |   for(int i=0;i<x.size();i++){
      |               ~^~~~~~~~~
vault.cpp:16:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for(int j=0;j<spa.size();j++){
      |                 ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4188 KB Output is correct
2 Correct 6 ms 4288 KB Output is correct
3 Correct 3 ms 4180 KB Output is correct
4 Correct 14 ms 4288 KB Output is correct
5 Correct 2 ms 4180 KB Output is correct
6 Correct 252 ms 4516 KB Output is correct
7 Correct 85 ms 4332 KB Output is correct
8 Correct 245 ms 4544 KB Output is correct
9 Correct 526 ms 4752 KB Output is correct
10 Correct 5 ms 4180 KB Output is correct
11 Correct 10 ms 4180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4188 KB Output is correct
2 Correct 6 ms 4288 KB Output is correct
3 Correct 3 ms 4180 KB Output is correct
4 Correct 14 ms 4288 KB Output is correct
5 Correct 2 ms 4180 KB Output is correct
6 Correct 252 ms 4516 KB Output is correct
7 Correct 85 ms 4332 KB Output is correct
8 Correct 245 ms 4544 KB Output is correct
9 Correct 526 ms 4752 KB Output is correct
10 Correct 5 ms 4180 KB Output is correct
11 Correct 10 ms 4180 KB Output is correct
12 Correct 8 ms 4180 KB Output is correct
13 Correct 7 ms 4180 KB Output is correct
14 Correct 4 ms 4176 KB Output is correct
15 Correct 16 ms 4296 KB Output is correct
16 Correct 3 ms 4180 KB Output is correct
17 Correct 244 ms 4500 KB Output is correct
18 Correct 80 ms 4380 KB Output is correct
19 Correct 246 ms 4548 KB Output is correct
20 Correct 511 ms 4744 KB Output is correct
21 Correct 5 ms 4180 KB Output is correct
22 Correct 9 ms 4180 KB Output is correct
23 Correct 2 ms 4180 KB Output is correct
24 Correct 3726 ms 6576 KB Output is correct
25 Correct 623 ms 5176 KB Output is correct
26 Execution timed out 5058 ms 8020 KB Time limit exceeded
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 4180 KB Output is correct
2 Incorrect 2 ms 4180 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 4180 KB Output is correct
2 Incorrect 2 ms 4180 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 4180 KB Output is correct
2 Incorrect 2 ms 4180 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4188 KB Output is correct
2 Correct 6 ms 4288 KB Output is correct
3 Correct 3 ms 4180 KB Output is correct
4 Correct 14 ms 4288 KB Output is correct
5 Correct 2 ms 4180 KB Output is correct
6 Correct 252 ms 4516 KB Output is correct
7 Correct 85 ms 4332 KB Output is correct
8 Correct 245 ms 4544 KB Output is correct
9 Correct 526 ms 4752 KB Output is correct
10 Correct 5 ms 4180 KB Output is correct
11 Correct 10 ms 4180 KB Output is correct
12 Correct 12 ms 4180 KB Output is correct
13 Incorrect 2 ms 4180 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 4180 KB Output is correct
2 Incorrect 2 ms 4180 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4188 KB Output is correct
2 Correct 6 ms 4288 KB Output is correct
3 Correct 3 ms 4180 KB Output is correct
4 Correct 14 ms 4288 KB Output is correct
5 Correct 2 ms 4180 KB Output is correct
6 Correct 252 ms 4516 KB Output is correct
7 Correct 85 ms 4332 KB Output is correct
8 Correct 245 ms 4544 KB Output is correct
9 Correct 526 ms 4752 KB Output is correct
10 Correct 5 ms 4180 KB Output is correct
11 Correct 10 ms 4180 KB Output is correct
12 Correct 8 ms 4180 KB Output is correct
13 Correct 7 ms 4180 KB Output is correct
14 Correct 4 ms 4176 KB Output is correct
15 Correct 16 ms 4296 KB Output is correct
16 Correct 3 ms 4180 KB Output is correct
17 Correct 244 ms 4500 KB Output is correct
18 Correct 80 ms 4380 KB Output is correct
19 Correct 246 ms 4548 KB Output is correct
20 Correct 511 ms 4744 KB Output is correct
21 Correct 5 ms 4180 KB Output is correct
22 Correct 9 ms 4180 KB Output is correct
23 Correct 2 ms 4180 KB Output is correct
24 Correct 3726 ms 6576 KB Output is correct
25 Correct 623 ms 5176 KB Output is correct
26 Execution timed out 5058 ms 8020 KB Time limit exceeded
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 4180 KB Output is correct
2 Incorrect 2 ms 4180 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4188 KB Output is correct
2 Correct 6 ms 4288 KB Output is correct
3 Correct 3 ms 4180 KB Output is correct
4 Correct 14 ms 4288 KB Output is correct
5 Correct 2 ms 4180 KB Output is correct
6 Correct 252 ms 4516 KB Output is correct
7 Correct 85 ms 4332 KB Output is correct
8 Correct 245 ms 4544 KB Output is correct
9 Correct 526 ms 4752 KB Output is correct
10 Correct 5 ms 4180 KB Output is correct
11 Correct 10 ms 4180 KB Output is correct
12 Correct 8 ms 4180 KB Output is correct
13 Correct 7 ms 4180 KB Output is correct
14 Correct 4 ms 4176 KB Output is correct
15 Correct 16 ms 4296 KB Output is correct
16 Correct 3 ms 4180 KB Output is correct
17 Correct 244 ms 4500 KB Output is correct
18 Correct 80 ms 4380 KB Output is correct
19 Correct 246 ms 4548 KB Output is correct
20 Correct 511 ms 4744 KB Output is correct
21 Correct 5 ms 4180 KB Output is correct
22 Correct 9 ms 4180 KB Output is correct
23 Correct 2 ms 4180 KB Output is correct
24 Correct 3726 ms 6576 KB Output is correct
25 Correct 623 ms 5176 KB Output is correct
26 Execution timed out 5058 ms 8020 KB Time limit exceeded
27 Halted 0 ms 0 KB -