Submission #591178

# Submission time Handle Problem Language Result Execution time Memory
591178 2022-07-07T00:45:16 Z jackkkk Cloud Computing (CEOI18_clo) C++17
100 / 100
395 ms 1356 KB
// Cloud Computing
// https://oj.uz/problem/view/CEOI18_clo


#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <array>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <list>
#include <float.h>
#include <climits>
#include <iomanip>
#include <chrono>

using namespace std;
using namespace std::chrono;

void quit() {
  cout.flush();
  exit(0);
}

struct entry {
  int c;
  int f;
  long long int v;
  bool operator< (const entry& other) const {
    if (f != other.f) {
      return f > other.f;
    }
    return c > other.c;
  }
};


int n, m;
vector<entry> entries;

constexpr int MAXDP = 100001;

long long int dp[MAXDP + 1];


int main(void){
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  entry te;

  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> te.c >> te.f >> te.v;
    te.v *= -1;
    entries.push_back(te);
  }

  cin >> m;
  for (int i = 0; i < m; ++i) {
    cin >> te.c >> te.f >> te.v;
    te.c *= -1;
    entries.push_back(te);
  }
  sort(entries.begin(), entries.end());

  for (int i = 0; i < MAXDP; ++i) {
    dp[i] = -9999999999999LL;
  }
  dp[0] = 0;


  for (const auto& entry : entries) {
    if (entry.c > 0) { // machine
      for (int i = MAXDP - 1; i >= entry.c; --i) {
        dp[i] = max(dp[i], dp[i - entry.c] + entry.v);
      }
    } else { // job
      for (int i = 0; i <= MAXDP - 1 + entry.c; ++i) {
        dp[i] = max(dp[i], dp[i - entry.c] + entry.v);
      }
    }
  }

  long long int ans = 0;
  for (int i = 0; i < MAXDP; ++i) {
    ans = max(ans, dp[i]);
  }

  cout << ans << std::endl;
  
  quit();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Correct 2 ms 1108 KB Output is correct
3 Correct 10 ms 1108 KB Output is correct
4 Correct 19 ms 1144 KB Output is correct
5 Correct 163 ms 1192 KB Output is correct
6 Correct 164 ms 1196 KB Output is correct
7 Correct 176 ms 1228 KB Output is correct
8 Correct 189 ms 1108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Correct 2 ms 1108 KB Output is correct
3 Correct 11 ms 1108 KB Output is correct
4 Correct 10 ms 1108 KB Output is correct
5 Correct 78 ms 1144 KB Output is correct
6 Correct 95 ms 1136 KB Output is correct
7 Correct 169 ms 1200 KB Output is correct
8 Correct 171 ms 1196 KB Output is correct
9 Correct 171 ms 1168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 980 KB Output is correct
2 Correct 4 ms 1108 KB Output is correct
3 Correct 16 ms 1236 KB Output is correct
4 Correct 16 ms 1108 KB Output is correct
5 Correct 33 ms 1112 KB Output is correct
6 Correct 36 ms 1116 KB Output is correct
7 Correct 43 ms 1116 KB Output is correct
8 Correct 43 ms 1108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1108 KB Output is correct
2 Correct 3 ms 1100 KB Output is correct
3 Correct 139 ms 1164 KB Output is correct
4 Correct 152 ms 1172 KB Output is correct
5 Correct 333 ms 1276 KB Output is correct
6 Correct 349 ms 1260 KB Output is correct
7 Correct 334 ms 1236 KB Output is correct
8 Correct 351 ms 1264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Correct 17 ms 1108 KB Output is correct
3 Correct 74 ms 1108 KB Output is correct
4 Correct 202 ms 1168 KB Output is correct
5 Correct 340 ms 1356 KB Output is correct
6 Correct 341 ms 1252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Correct 2 ms 1108 KB Output is correct
3 Correct 10 ms 1108 KB Output is correct
4 Correct 19 ms 1144 KB Output is correct
5 Correct 163 ms 1192 KB Output is correct
6 Correct 164 ms 1196 KB Output is correct
7 Correct 176 ms 1228 KB Output is correct
8 Correct 189 ms 1108 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 2 ms 1108 KB Output is correct
11 Correct 11 ms 1108 KB Output is correct
12 Correct 10 ms 1108 KB Output is correct
13 Correct 78 ms 1144 KB Output is correct
14 Correct 95 ms 1136 KB Output is correct
15 Correct 169 ms 1200 KB Output is correct
16 Correct 171 ms 1196 KB Output is correct
17 Correct 171 ms 1168 KB Output is correct
18 Correct 4 ms 980 KB Output is correct
19 Correct 4 ms 1108 KB Output is correct
20 Correct 16 ms 1236 KB Output is correct
21 Correct 16 ms 1108 KB Output is correct
22 Correct 33 ms 1112 KB Output is correct
23 Correct 36 ms 1116 KB Output is correct
24 Correct 43 ms 1116 KB Output is correct
25 Correct 43 ms 1108 KB Output is correct
26 Correct 2 ms 1108 KB Output is correct
27 Correct 3 ms 1100 KB Output is correct
28 Correct 139 ms 1164 KB Output is correct
29 Correct 152 ms 1172 KB Output is correct
30 Correct 333 ms 1276 KB Output is correct
31 Correct 349 ms 1260 KB Output is correct
32 Correct 334 ms 1236 KB Output is correct
33 Correct 351 ms 1264 KB Output is correct
34 Correct 1 ms 1108 KB Output is correct
35 Correct 17 ms 1108 KB Output is correct
36 Correct 74 ms 1108 KB Output is correct
37 Correct 202 ms 1168 KB Output is correct
38 Correct 340 ms 1356 KB Output is correct
39 Correct 341 ms 1252 KB Output is correct
40 Correct 98 ms 1132 KB Output is correct
41 Correct 178 ms 1180 KB Output is correct
42 Correct 274 ms 1244 KB Output is correct
43 Correct 348 ms 1276 KB Output is correct
44 Correct 395 ms 1280 KB Output is correct
45 Correct 341 ms 1304 KB Output is correct
46 Correct 174 ms 1192 KB Output is correct
47 Correct 276 ms 1252 KB Output is correct
48 Correct 250 ms 1252 KB Output is correct