# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1026087 | 2024-07-17T14:18:21 Z | coolsentenceidontremember | Cloud Computing (CEOI18_clo) | C++17 | 610 ms | 2140 KB |
#include<bits/stdc++.h> #pragma GCC optimize("O3", "unroll-loops") #define ll long long #define ld long double #define ff first #define ss second #define db double #define time_begin() auto begin = chrono::high_resolution_clock::now() #define time_end() auto end = chrono::high_resolution_clock::now(); auto elapsed = chrono::duration_cast<chrono::nanoseconds>(end-begin); auto sec = elapsed.count() * 1e-9; cerr << "\n\nExecution time: " << sec << " seconds"; #define check_time() cerr << "\nStatus : "; if (sec>1) cerr << "Time Limit Exceeded 1!!!1!111"; else cerr << "You good brother" using namespace std; void setIO(string s = ""){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); if (!s.empty()){ freopen((s+".in").c_str(), "r", stdin); freopen((s+".out").c_str(), "w", stdout); } } const auto inf = LLONG_MAX; const ll mod = 1e9 + 7; ll pow_mod(ll a, ll b, ll m = mod){ if (!a) return 0; a %= mod; ll res = 1; for (;b;b>>=1, a = (a*a)%mod){ if (b&1) res = (res*a)%mod; } return res; } struct obj{ bool computer; int core; int clock; ll profit; }; bool cmp(const obj &a, const obj&b){ if (a.clock != b.clock) return a.clock > b.clock; else if (a.computer != b.computer) return (a.computer); else if (!a.computer) return a.profit > b.profit; else return a.profit < b.profit; } int main(){ setIO(); int n; cin >> n; vector<obj> v; int total_core = 0; for (int i=1; i <= n; i++){ obj c; cin >> c.core >> c.clock >> c.profit; c.computer = 1; total_core += c.core; v.push_back(c); } int m; cin >> m; for (int i = 1; i <= m; i++){ obj o; cin >> o.core >> o.clock >> o.profit; o.computer = 0; v.push_back(o); } sort(v.begin(), v.end(), cmp); vector<ll> dp1(total_core+1, -inf); dp1[0] = 0; for (int i = 0; i < n+m; i++){ obj cur = v[i]; vector<ll> dp2(dp1); if (cur.computer) cur.profit = -cur.profit; else cur.core = -cur.core; for (int c = 0; c <= total_core; c++){ int past = c - cur.core; if (past >= 0 && past <= total_core && dp1[past] != -inf){ // cout << i << ' ' << c << ' ' << past << ' ' << cur.profit << ' ' << dp1[past] << '\n'; dp2[c] = max(dp2[c], dp1[past] + cur.profit); } } dp1 = dp2; } cout << *max_element(dp1.begin(), dp1.end()) << '\n'; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 344 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 2 ms | 348 KB | Output is correct |
8 | Correct | 3 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 27 ms | 860 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 138 ms | 1624 KB | Output is correct |
8 | Correct | 22 ms | 604 KB | Output is correct |
9 | Correct | 233 ms | 1884 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 344 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 464 KB | Output is correct |
8 | Correct | 1 ms | 344 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 8 ms | 592 KB | Output is correct |
4 | Correct | 2 ms | 348 KB | Output is correct |
5 | Correct | 251 ms | 1484 KB | Output is correct |
6 | Correct | 515 ms | 1944 KB | Output is correct |
7 | Correct | 470 ms | 1940 KB | Output is correct |
8 | Correct | 534 ms | 1968 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 452 KB | Output is correct |
3 | Correct | 24 ms | 916 KB | Output is correct |
4 | Correct | 5 ms | 348 KB | Output is correct |
5 | Correct | 475 ms | 2076 KB | Output is correct |
6 | Correct | 538 ms | 1944 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 344 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 2 ms | 348 KB | Output is correct |
8 | Correct | 3 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 344 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 27 ms | 860 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 138 ms | 1624 KB | Output is correct |
16 | Correct | 22 ms | 604 KB | Output is correct |
17 | Correct | 233 ms | 1884 KB | Output is correct |
18 | Correct | 1 ms | 344 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 1 ms | 348 KB | Output is correct |
22 | Correct | 1 ms | 344 KB | Output is correct |
23 | Correct | 1 ms | 348 KB | Output is correct |
24 | Correct | 1 ms | 464 KB | Output is correct |
25 | Correct | 1 ms | 344 KB | Output is correct |
26 | Correct | 0 ms | 348 KB | Output is correct |
27 | Correct | 0 ms | 348 KB | Output is correct |
28 | Correct | 8 ms | 592 KB | Output is correct |
29 | Correct | 2 ms | 348 KB | Output is correct |
30 | Correct | 251 ms | 1484 KB | Output is correct |
31 | Correct | 515 ms | 1944 KB | Output is correct |
32 | Correct | 470 ms | 1940 KB | Output is correct |
33 | Correct | 534 ms | 1968 KB | Output is correct |
34 | Correct | 0 ms | 344 KB | Output is correct |
35 | Correct | 1 ms | 452 KB | Output is correct |
36 | Correct | 24 ms | 916 KB | Output is correct |
37 | Correct | 5 ms | 348 KB | Output is correct |
38 | Correct | 475 ms | 2076 KB | Output is correct |
39 | Correct | 538 ms | 1944 KB | Output is correct |
40 | Correct | 28 ms | 860 KB | Output is correct |
41 | Correct | 81 ms | 1116 KB | Output is correct |
42 | Correct | 6 ms | 600 KB | Output is correct |
43 | Correct | 531 ms | 2140 KB | Output is correct |
44 | Correct | 524 ms | 2136 KB | Output is correct |
45 | Correct | 610 ms | 2136 KB | Output is correct |
46 | Correct | 3 ms | 344 KB | Output is correct |
47 | Correct | 6 ms | 604 KB | Output is correct |
48 | Correct | 5 ms | 600 KB | Output is correct |