제출 #146106

#제출 시각아이디문제언어결과실행 시간메모리
146106raghav0307Cloud Computing (CEOI18_clo)C++14
72 / 100
3031 ms5060 KiB
// Kamil Debowski // OBL, AC solution #include <bits/stdc++.h> using namespace std; typedef long long ll; #define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int main() { fast_io() 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:12:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &n);
   ~~~~~^~~~~~~~~~
clo.cpp:15: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...