Submission #482286

# Submission time Handle Problem Language Result Execution time Memory
482286 2021-10-24T02:15:31 Z Olympia Cloud Computing (CEOI18_clo) C++17
54 / 100
356 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] = -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;
}

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++) {
      |                     ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 1 ms 972 KB Output is correct
3 Correct 11 ms 1100 KB Output is correct
4 Correct 19 ms 1096 KB Output is correct
5 Correct 173 ms 1156 KB Output is correct
6 Correct 170 ms 1100 KB Output is correct
7 Correct 179 ms 1100 KB Output is correct
8 Correct 185 ms 1200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 2 ms 972 KB Output is correct
3 Correct 10 ms 1092 KB Output is correct
4 Correct 10 ms 972 KB Output is correct
5 Correct 85 ms 1120 KB Output is correct
6 Correct 83 ms 1116 KB Output is correct
7 Correct 182 ms 1164 KB Output is correct
8 Correct 178 ms 1100 KB Output is correct
9 Incorrect 172 ms 1100 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 972 KB Output is correct
2 Correct 4 ms 972 KB Output is correct
3 Correct 17 ms 1096 KB Output is correct
4 Correct 18 ms 1092 KB Output is correct
5 Correct 33 ms 1100 KB Output is correct
6 Correct 36 ms 1100 KB Output is correct
7 Correct 46 ms 1100 KB Output is correct
8 Correct 45 ms 1100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 972 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 972 KB Output is correct
2 Correct 15 ms 972 KB Output is correct
3 Correct 77 ms 1116 KB Output is correct
4 Correct 192 ms 1160 KB Output is correct
5 Correct 356 ms 1256 KB Output is correct
6 Correct 348 ms 1228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 1 ms 972 KB Output is correct
3 Correct 11 ms 1100 KB Output is correct
4 Correct 19 ms 1096 KB Output is correct
5 Correct 173 ms 1156 KB Output is correct
6 Correct 170 ms 1100 KB Output is correct
7 Correct 179 ms 1100 KB Output is correct
8 Correct 185 ms 1200 KB Output is correct
9 Correct 1 ms 972 KB Output is correct
10 Correct 2 ms 972 KB Output is correct
11 Correct 10 ms 1092 KB Output is correct
12 Correct 10 ms 972 KB Output is correct
13 Correct 85 ms 1120 KB Output is correct
14 Correct 83 ms 1116 KB Output is correct
15 Correct 182 ms 1164 KB Output is correct
16 Correct 178 ms 1100 KB Output is correct
17 Incorrect 172 ms 1100 KB Output isn't correct