답안 #400390

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
400390 2021-05-07T22:54:16 Z abdzag Cloud Computing (CEOI18_clo) C++17
100 / 100
1466 ms 5316 KB
#include<bits/stdc++.h>
#include<unordered_map>
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define rrep(i,a,b) for(int i=int(a);i>int(b);i--)
#define all(v) v.begin(),v.end()
#define trav(a,v) for(auto&a:v)
#define  sz(a) a.size()
typedef long double ld;
using namespace std;
const long long inf = 1e15;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    cin.sync_with_stdio(false);
    ll n, m;
    cin >> n;
    vector<pair<pair<ll, ll>, pair<ll, ll>>> v(n);
    rep(i, 0, n) {
        cin >> v[i].second.first >> v[i].first.first >> v[i].second.second;
        v[i].first.first *= -1;
    }
    cin >> m;
    v.resize(n + m);
    rep(i, n, n + m) {
        cin >> v[i].second.first >> v[i].first.first >> v[i].second.second;
        v[i].first.first *= -1;
        v[i].first.second = 1;
    }
    sort(all(v));
    vector<ll>dp(3e5, -inf);
    dp[0] = 0;
    vector<ll> dp0 = dp;
    ll sumc = 1;
    rep(i, 0, n + m) {
        if (!v[i].first.second) {
            rep(j, 0, sumc) if (dp0[j] != -inf)dp[v[i].second.first + j] = max(dp0[v[i].second.first + j], dp0[j] - v[i].second.second);
        }
        else {
            rep(j, v[i].second.first, sumc)if (dp0[j] != -inf)dp[-v[i].second.first + j] = max(dp0[-v[i].second.first + j], dp0[j] + v[i].second.second);
        }
        sumc += v[i].second.first;
        dp0 = dp;
    }
    ll ans = 0;
    rep(i, 0, 3e5)ans = max(dp[i], ans);
    cout << ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 4 ms 4940 KB Output is correct
3 Correct 15 ms 4940 KB Output is correct
4 Correct 25 ms 4940 KB Output is correct
5 Correct 269 ms 5056 KB Output is correct
6 Correct 221 ms 5072 KB Output is correct
7 Correct 309 ms 5128 KB Output is correct
8 Correct 306 ms 5116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4940 KB Output is correct
2 Correct 6 ms 4940 KB Output is correct
3 Correct 17 ms 5028 KB Output is correct
4 Correct 15 ms 5020 KB Output is correct
5 Correct 146 ms 5064 KB Output is correct
6 Correct 102 ms 5088 KB Output is correct
7 Correct 404 ms 5196 KB Output is correct
8 Correct 246 ms 5196 KB Output is correct
9 Correct 493 ms 5060 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4940 KB Output is correct
2 Correct 7 ms 5016 KB Output is correct
3 Correct 24 ms 5040 KB Output is correct
4 Correct 23 ms 4940 KB Output is correct
5 Correct 43 ms 5028 KB Output is correct
6 Correct 54 ms 5032 KB Output is correct
7 Correct 61 ms 5040 KB Output is correct
8 Correct 60 ms 5080 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4940 KB Output is correct
2 Correct 5 ms 4940 KB Output is correct
3 Correct 182 ms 5112 KB Output is correct
4 Correct 199 ms 5068 KB Output is correct
5 Correct 894 ms 5244 KB Output is correct
6 Correct 1466 ms 5240 KB Output is correct
7 Correct 1459 ms 5316 KB Output is correct
8 Correct 1392 ms 5232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4940 KB Output is correct
2 Correct 22 ms 5024 KB Output is correct
3 Correct 135 ms 5068 KB Output is correct
4 Correct 234 ms 5108 KB Output is correct
5 Correct 1270 ms 5244 KB Output is correct
6 Correct 1459 ms 5316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 4 ms 4940 KB Output is correct
3 Correct 15 ms 4940 KB Output is correct
4 Correct 25 ms 4940 KB Output is correct
5 Correct 269 ms 5056 KB Output is correct
6 Correct 221 ms 5072 KB Output is correct
7 Correct 309 ms 5128 KB Output is correct
8 Correct 306 ms 5116 KB Output is correct
9 Correct 4 ms 4940 KB Output is correct
10 Correct 6 ms 4940 KB Output is correct
11 Correct 17 ms 5028 KB Output is correct
12 Correct 15 ms 5020 KB Output is correct
13 Correct 146 ms 5064 KB Output is correct
14 Correct 102 ms 5088 KB Output is correct
15 Correct 404 ms 5196 KB Output is correct
16 Correct 246 ms 5196 KB Output is correct
17 Correct 493 ms 5060 KB Output is correct
18 Correct 7 ms 4940 KB Output is correct
19 Correct 7 ms 5016 KB Output is correct
20 Correct 24 ms 5040 KB Output is correct
21 Correct 23 ms 4940 KB Output is correct
22 Correct 43 ms 5028 KB Output is correct
23 Correct 54 ms 5032 KB Output is correct
24 Correct 61 ms 5040 KB Output is correct
25 Correct 60 ms 5080 KB Output is correct
26 Correct 6 ms 4940 KB Output is correct
27 Correct 5 ms 4940 KB Output is correct
28 Correct 182 ms 5112 KB Output is correct
29 Correct 199 ms 5068 KB Output is correct
30 Correct 894 ms 5244 KB Output is correct
31 Correct 1466 ms 5240 KB Output is correct
32 Correct 1459 ms 5316 KB Output is correct
33 Correct 1392 ms 5232 KB Output is correct
34 Correct 4 ms 4940 KB Output is correct
35 Correct 22 ms 5024 KB Output is correct
36 Correct 135 ms 5068 KB Output is correct
37 Correct 234 ms 5108 KB Output is correct
38 Correct 1270 ms 5244 KB Output is correct
39 Correct 1459 ms 5316 KB Output is correct
40 Correct 175 ms 5068 KB Output is correct
41 Correct 398 ms 5116 KB Output is correct
42 Correct 326 ms 5196 KB Output is correct
43 Correct 962 ms 5248 KB Output is correct
44 Correct 962 ms 5196 KB Output is correct
45 Correct 994 ms 5292 KB Output is correct
46 Correct 225 ms 5068 KB Output is correct
47 Correct 330 ms 5200 KB Output is correct
48 Correct 315 ms 5196 KB Output is correct