답안 #482285

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
482285 2021-10-24T02:15:01 Z Olympia Cloud Computing (CEOI18_clo) C++17
36 / 100
358 ms 1256 KB
#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] = -(long long)1e12;
    }
    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;
}

Compilation message

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++) {
      |                     ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 1 ms 972 KB Output is correct
3 Correct 10 ms 972 KB Output is correct
4 Correct 19 ms 1092 KB Output is correct
5 Correct 170 ms 1164 KB Output is correct
6 Correct 171 ms 1220 KB Output is correct
7 Incorrect 178 ms 1228 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 2 ms 972 KB Output is correct
3 Correct 10 ms 972 KB Output is correct
4 Correct 13 ms 1088 KB Output is correct
5 Correct 83 ms 1112 KB Output is correct
6 Correct 85 ms 1108 KB Output is correct
7 Correct 183 ms 1100 KB Output is correct
8 Correct 182 ms 1160 KB Output is correct
9 Incorrect 173 ms 1100 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 972 KB Output is correct
2 Correct 4 ms 972 KB Output is correct
3 Correct 16 ms 1100 KB Output is correct
4 Correct 17 ms 972 KB Output is correct
5 Correct 38 ms 1100 KB Output is correct
6 Correct 35 ms 1100 KB Output is correct
7 Correct 45 ms 1100 KB Output is correct
8 Correct 45 ms 1100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 972 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 972 KB Output is correct
2 Correct 22 ms 1092 KB Output is correct
3 Correct 78 ms 1116 KB Output is correct
4 Correct 191 ms 1164 KB Output is correct
5 Correct 347 ms 1228 KB Output is correct
6 Correct 358 ms 1256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 1 ms 972 KB Output is correct
3 Correct 10 ms 972 KB Output is correct
4 Correct 19 ms 1092 KB Output is correct
5 Correct 170 ms 1164 KB Output is correct
6 Correct 171 ms 1220 KB Output is correct
7 Incorrect 178 ms 1228 KB Output isn't correct
8 Halted 0 ms 0 KB -