제출 #486557

#제출 시각아이디문제언어결과실행 시간메모리
486557john256Cloud Computing (CEOI18_clo)C++11
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; struct Transaction { int cores; int rate; int price; }; int main() { vector<Transaction> poss_transactions; //possible transactions int maxC = 0; //max # of CPUS int N; cin >> N; //# of computers available for(int x=0; x<N; x++) { Transaction trans; cin >> trans.cores >> trans.rate >> trans.price; trans.price = -trans.price; poss_transactions.push_back(trans); maxC += trans.cores; } int M; cin >> M; //# of orders from customers for(int y=0; y<M; y++) { Transaction trans; cin >> trans.cores >> trans.rate >> trans.price; trans.cores = -trans.cores; poss_transactions.push_back(trans); } //The clock rate issue goes away if we process the orders in order. sort( poss_transactions.begin(), poss_transactions.end(), [](const Transaction& a, const Transaction& b) { return a.rate != b.rate ? a.rate > b.rate : a.price < b.price; }); /* * dp[t][c] = the maximum profit we can gain from the first * t transactions given that we have c cores left */ vector<long long> max_profits(maxC+1, INT64_MIN); dp[0] = 0; for(const Transaction& t : poss_transactions) { vector<long long> dp2(dp); //updated dp array after transaction t for(int c=0; c<=maxC; c++) { int prev_comp = c - t.cores; if(0 <= prev_comp && prev_comp <= maxC && dp[prev_comp] != INT64_MIN) { dp2[c] = max(dp2[c], dp[prev_comp] + t.price); } } dp = dp2; } cout << *max_element(dp.begin(), dp.end()) << endl; }

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

clo.cpp: In function 'int main()':
clo.cpp:44:2: error: 'dp' was not declared in this scope
   44 |  dp[0] = 0;
      |  ^~