# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
165388 | Lawliet | Cloud Computing (CEOI18_clo) | C++14 | 13 ms | 1912 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long int lli;
const int MAXN = 300;
int n, m;
lli dp[MAXN][MAXN];
vector< pii > buy;
vector< pii > sell;
lli solve(int i, int j)
{
if( i < 0 || j < 0 ) return 0;
lli& ans = dp[i][j];
if( ans != -1 ) return ans;
ans = max( solve( i - 1 , j ) , solve( i , j - 1 ) );
if( buy[i].first >= sell[j].first )
{
lli cost = sell[j].second - buy[i].second;
ans = max( ans , solve( i - 1 , j - 1 ) + cost );
}
ans = max( ans , 0LL );
return ans;
}
int main()
{
scanf("%d %d",&n,&m);
memset( dp , -1 , sizeof(dp) );
for(int i = 1 ; i <= n ; i++)
{
int c, f, v;
scanf("%d %d %d",&c,&f,&v);
buy.push_back( { f , v } );
}
for(int i = 1 ; i <= m ; i++)
{
int c, f, v;
scanf("%d %d %d",&c,&f,&v);
sell.push_back( { f , v } );
}
sort(buy.begin() , buy.end());
sort(sell.begin() , sell.end());
printf("%lld\n",solve( n - 1 , m - 1 ));
}
컴파일 시 표준 에러 (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... |