| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 30814 | TAMREF | 스트랩 (JOI14_straps) | C++11 | 946 ms | 262144 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ilb INT_MIN
using namespace std;
unordered_map<int,int> dp[2005], vis[2005];
pair<int,int> f[2005];
int N;
void input(){
scanf("%d",&N);
for(int i=0;i<N;i++) scanf("%d %d",&f[i].first,&f[i].second);
sort(f,f+N,greater<pair<int,int>>());
dp[0][1]=0;
}
void work_dp(){
for(int i=0;i<N;i++){
for(auto x : dp[i]){
if(!vis[i+1][x.first]){
dp[i+1][x.first]=ilb;
vis[i+1][x.first]=1;
}
dp[i+1][x.first]=max(dp[i+1][x.first],x.second);
if(!x.first) continue;
if(!vis[i+1][x.first+f[i].first-1]){
dp[i+1][x.first+f[i].first-1]=ilb;
vis[i+1][x.first+f[i].first-1]=1;
}
dp[i+1][x.first+f[i].first-1]=max(dp[i+1][x.first+f[i].first-1],x.second+f[i].second);
}
}
}
void output(){
int t=0;
for(auto x : dp[N]) t=max(t,x.second);
printf("%d\n",t);
}
int main(){
input();
work_dp();
output();
}
컴파일 시 표준 에러 (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... | ||||
