제출 #934407

#제출 시각아이디문제언어결과실행 시간메모리
934407garamlee500Cloud Computing (CEOI18_clo)C++17
100 / 100
347 ms1616 KiB
#include <cmath> #include <iostream> #include <set> #include <climits> #include <algorithm> #include <vector> #include <iomanip> #include <type_traits> #include <string> #include <queue> #include <map> using namespace std; struct Order { long long price; //price we gain long long clockspeed; //clockspeed long long cores; //cores we gain }; bool comp (Order o1, Order o2) { if (o1.clockspeed != o2.clockspeed) { return (o1.clockspeed > o2.clockspeed); } return (o1.price < o2.price); } void print(Order a) { cout << "PRICE: " << a.price << endl; cout << "CLOCKSPEED: " << a.clockspeed << endl; cout << "CORES " << a.cores << endl; cout << "------\n"; } int main() { int n; cin >> n; vector<Order> v; for (int i = 0; i < n; i++) { Order a; cin >> a.cores >> a.clockspeed >> a.price; a.price = -a.price; v.push_back(a); } int m; cin >> m; for (int i = 0; i < m; i++) { Order a; cin >> a.cores >> a.clockspeed >> a.price; a.cores = -a.cores; v.push_back(a); } sort(v.begin(), v.end(), comp); vector<long long> dp ((int)1e5 + 10); for (int i = 0; i < dp.size(); i++) { dp[i] = -LLONG_MAX/3; } dp[0] = 0; long long myMax = 0; for (auto p: v) { if (p.cores > 0 ) { //buy a computer for (int i = dp.size() - 1; i >= 0; i--) { if (i - abs(p.cores) < 0) continue; dp[i] = max(dp[i], dp[i - abs(p.cores)] - abs(p.price)); } } else { //customer for (int i = 0; i < dp.size(); i++) { if (i + abs(p.cores) >= dp.size()) continue; dp[i] = max(dp[i], dp[i + abs(p.cores)] + abs(p.price)); } } } for (int i = 0; i < dp.size(); i++) { myMax = max(myMax, dp[i]); } cout << myMax << endl; }

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

clo.cpp: In function 'int main()':
clo.cpp:50:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for (int i = 0; i < dp.size(); i++) {
      |                     ~~^~~~~~~~~~~
clo.cpp:64:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |             for (int i = 0; i < dp.size(); i++) {
      |                             ~~^~~~~~~~~~~
clo.cpp:65:38: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |                 if (i + abs(p.cores) >= dp.size()) continue;
      |                     ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
clo.cpp:70:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |     for (int i = 0; i < dp.size(); i++) {
      |                     ~~^~~~~~~~~~~
#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...