# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
588666 | peuch | Uplifting Excursion (BOI22_vault) | C++17 | 3 ms | 4564 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
const int MAXN = 101;
const int MAXA = 101 * 100 * 101 - 8e5;
const long long INF = 1e18;
const int HALF = MAXA / 2;
int m;
long long l;
long long v[2 * MAXN];
long long dp[2][MAXA];
int main(){
scanf("%d %lld", &m, &l);
long long sum = 0;
long long cnt = 0;
vector<pair<long long, long long> > moedas;
for(long long i = -m; i <= m; i++){
scanf("%lld", &v[i + m]);
sum += v[i + m] * i;
cnt += v[i + m];
long long aux = v[i + m];
long long tam = 1;
while(aux > 0){
moedas.push_back(make_pair(i * tam, tam));
aux--;
if(aux % 2 == 1){
moedas.push_back(make_pair(i * tam, tam));
aux--;
}
aux /= 2;
tam *= 2;
}
}
if(l + HALF >= MAXA || l + HALF < 0){
printf("impossible\n");
return 0;
}
for(long long j = 0; j < MAXA; j++)
dp[1][j] = dp[0][j] = INF;
dp[0][HALF] = 0;
vector<int> founds(1, HALF);
vector<int> marc(MAXA);
marc[HALF] = 1;
for(auto val : moedas){
queue<int> auxFound;
for(int j : founds){
if(j + val.first >= MAXA && j + val.first < 0) continue;
dp[1][j + val.first] = min(dp[1][j + val.first], dp[0][j] + val.second);
auxFound.push(j + val.first);
}
while(!auxFound.empty()){
int j = auxFound.front();
auxFound.pop();
dp[0][j] = dp[1][j];
if(!marc[j]) marc[j] = 1, founds.push_back(j);
}
}
if(dp[0][sum - l + HALF] == INF) printf("impossible\n");
else printf("%lld\n", cnt - dp[0][sum - l + HALF]);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |