Submission #1113688

#TimeUsernameProblemLanguageResultExecution timeMemory
1113688akacool445kCloud Computing (CEOI18_clo)C++14
0 / 100
228 ms262144 KiB
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
// #define int long long
#define pint pair<int, int>
#define vint vector<pair<int, int>>
const int mod = 1e9 + 7;
const int shrek = 4001 * 20;
const int say = INT_MAX;
const int gex = INT_MIN;
const long long oo = 1e18;
int dp[4001][2001 * 20];
// int dif = 20 * 4000;
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    vector<array<int, 3>> v;
    int n; cin >> n;
    for(int i = 0; i < n; i++) {
        int a, b , c; cin >> a >> b >> c;
        v.pb({b, -c, a});
    }
    int m; cin >> m;
    for(int i = 0; i < m; i++) {
        int a, b, c; cin >> a >> b >> c;
        v.pb({b, c, -a});
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    int len = n + m;
    for(int i = 0; i <= 4000; i++) {
        for(int j = 0; j < shrek; j++) {
            dp[i][j] = -1e9;
        }
    }
    for(int i = 0; i < shrek; i++) dp[0][0] = 0;
    for(int i = 1; i <= len; i++) {
        for(int j = 0; j < shrek; j++) {
            if(0 <= j + v[i][2] && v[i][2] <= shrek) {
                dp[i][j + v[i][2]] = max(dp[i - 1][j + v[i][2]], dp[i - 1][j] + v[i][1]);
            }
        }
    }
    int ans = 0;
    for(int i = 0; i <= len; i++) {
        for(int j = 0; j < shrek; j++) {
            ans = max(ans, dp[i][j]);
        }
    }
    cout << ans << '\n';


    return 0;
}

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:36:22: warning: iteration 40020 invokes undefined behavior [-Waggressive-loop-optimizations]
   36 |             dp[i][j] = -1e9;
      |             ~~~~~~~~~^~~~~~
clo.cpp:35:26: note: within this loop
   35 |         for(int j = 0; j < shrek; j++) {
      |                        ~~^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...