# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
307024 | VROOM_VARUN | Cloud Computing (CEOI18_clo) | C++14 | 585 ms | 1528 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
struct Event {
enum Type { Processor, Task };
Type type;
int cores, frequency, price;
Event(Type type, int cores, int frequency, int price)
: type(type), cores(cores), frequency(frequency), price(price) { }
};
const int MAXN = 2005, MAXC = 55, MAXDP = MAXN*MAXC;
const long long int INF = 1000000000000000000LL; // 10^18
int n,m;
vector<Event> events;
long long int dp[MAXDP];
bool comp(const Event& event1, const Event& event2) {
if (event1.frequency == event2.frequency)
return event1.type < event2.type;
return event1.frequency > event2.frequency;
}
int main() {
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
int c,f,v;
scanf("%d%d%d", &c, &f, &v);
events.push_back(Event(Event::Processor,c,f,v));
}
scanf("%d", &m);
for (int i = 0; i < m; ++i) {
int c,f,v;
scanf("%d%d%d", &c, &f, &v);
events.push_back(Event(Event::Task,c,f,v));
}
sort(events.begin(), events.end(), comp);
for (int i = 0; i < MAXDP; ++i)
dp[i] = -INF;
dp[0] = 0;
for (int i = 0; i < (int)events.size(); ++i)
if (events[i].type == Event::Processor)
for (int j = MAXDP-1; j >= 0; --j) {
int index = j + events[i].cores;
long long int value = dp[j] - events[i].price;
if (index < MAXDP && dp[index] < value)
dp[index] = value;
}
else
for (int j = 0; j < MAXDP; ++j) {
int index = j - events[i].cores;
long long int value = dp[j] + events[i].price;
if (index >= 0 && dp[j] != -INF && dp[index] < value)
dp[index] = value;
}
long long int result = 0;
for (int i = 0; i < MAXDP; ++i)
result = max(result, dp[i]);
printf("%lld\n", result);
}
컴파일 시 표준 에러 (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... |