# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
96173 | AKaan37 | 학교 설립 (IZhO13_school) | C++17 | 2110 ms | 263168 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef pair< int,int > PII;
typedef long long int lo;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid (bas+son)/2
const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 1000005;
const lo mod = 1000000007;
lo n,m,cev,b,a[li],hak1,hak2;
map< pair< lo,pair < lo,lo > > ,lo > mpp;
//~ map<int,int>
string s;
pair<lo,lo> p[li];
pair<lo,lo> pp[li];
vector<int> v;
lo f(lo sira,lo hakk,lo hakk1){
lo mx=-inf;
if(hakk<0) return -inf;
if(hakk1<0) return -inf;
if(sira>n){
if(hakk==0 && hakk1==0)
return 0;
return -inf;
}
if(mpp.find(mp(sira,mp(hakk,hakk1)))!=mpp.end()) return mpp[mp(sira,mp(hakk,hakk1))];
mx=max(mx,f(sira+1,hakk-1,hakk1)+p[sira].fi);
mx=max(mx,f(sira+1,hakk,hakk1-1)+p[sira].se);
mx=max(mx,f(sira+1,hakk,hakk1));
return mpp[mp(sira,mp(hakk,hakk1))]=mx;
}
int main(){
scanf("%lld %lld %lld",&n,&hak1,&hak2);
FOR{
scanf("%lld %lld",&p[i].fi,&p[i].se);
pp[i].se=p[i].fi;
pp[i].fi=p[i].se;
//~ p[i].se=pp[i].fi;
//~ pp[i].se=p[i].fi;
}
//~ sort(p+1,p+n+1);
//~ sort(pp+1,pp+n+1);
//~ reverse(p+1,p+n+1);
//~ reverse(pp+1,pp+n+1);
printf("%lld\n",f(1,hak1,hak2));
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |