제출 #70177

#제출 시각아이디문제언어결과실행 시간메모리
70177model_codeCloud Computing (CEOI18_clo)C++17
100 / 100
2436 ms5800 KiB
// Kamil Debowski
// OBL, AC solution
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	vector<pair<int, pair<int,int>>> events;
	for(int rep = 0; rep < 2; ++rep) {
		int n;
		scanf("%d", &n);
		while(n--) {
			int cnt, freq, cost;
			scanf("%d%d%d", &cnt, &freq, &cost);
			if(rep == 0) {
				cost *= -1; // cost of CPU
			}
			else {
				cnt *= -1;
			}
			// otherwise gain from a task
			events.push_back({freq, {cnt, cost}});
		}
	}
	sort(events.rbegin(), events.rend());
	vector<ll> dp{0};
	for(int i = 0; i < (int) events.size(); ++i) {
		vector<ll> dp2 = dp;
		for(int cnt = 0; cnt < (int) dp.size(); ++cnt) {
			int cnt2 = cnt + events[i].second.first;
			ll maybe_cost = dp[cnt] + events[i].second.second;
			if(cnt2 >= 0) {
				while((int) dp2.size() <= cnt2) dp2.push_back(LONG_LONG_MIN / 2);
				dp2[cnt2] = max(dp2[cnt2], maybe_cost);
			}
		}
		dp = dp2;
	}
	ll answer = 0;
	for(ll x : dp) answer = max(answer, x);
	printf("%lld\n", answer);
}

컴파일 시 표준 에러 (stderr) 메시지

clo.cpp: In function 'int main()':
clo.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &n);
   ~~~~~^~~~~~~~~~
clo.cpp:13:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d%d%d", &cnt, &freq, &cost);
    ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...