제출 #1192195

#제출 시각아이디문제언어결과실행 시간메모리
1192195souvenir_vayneCloud Computing (CEOI18_clo)C++17
18 / 100
644 ms1984 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <chrono>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define f first
#define fin cin
#define int long long
#define fout cout
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cerr << "DEBUG " << x << endl
#define debug2(x, y) cerr << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cerr << "DEBUG " << x << " " << y << " " << z << endl
#define debug4(x, y, z, o) cerr << "DEBUG " << x << " " << y << " " << z << " " << o << endl
#define all(x) x.begin(), x.end()
#define left esquerda
#define lb lower_bound
#define right direita
using namespace std;
void setIO(string s) {
    ios_base::sync_with_stdio(0); cin.tie(0);
    freopen((s+".in").c_str(),"r",stdin);
    freopen((s+".out").c_str(),"w",stdout);
}
typedef pair<ll, ll> pii;
typedef vector<vector<char>> mat;
typedef pair<int, string> pis;
const ll mod = 1e9 + 7;
typedef vector<int> vi;
typedef pair<int, pair<int, int>> piii;


int32_t main() {
    FAST;
    int n;
    cin >> n;

    vector<array<int, 3>> v(n);
    int mc = 0;
    for(int i = 0; i < n; i++) {
        cin >> v[i][0] >> v[i][1] >> v[i][2];
        mc += v[i][0];
        v[i][2] = -v[i][2];
    }

    int m;
    cin >> m;
    v.resize(n + m);
    for(int i = n; i < n + m; i++) {
        cin >> v[i][0] >> v[i][1] >> v[i][2];
        v[i][0] = -v[i][0];
    }

    ll dp[mc + 5][2];
    for(int i = 0; i <= 1; i++)
        for(int j = 1; j < mc + 5; j++)
            dp[j][i] = -LINF;

    ll ans = 0;
    sort(all(v), [&](array<int, 3> a, array<int, 3> b) -> bool {
        return a[1] > b[1];
    });
    
    dp[0][0] = 0;
    for(int i = 0; i < n + m; i++)
        for(int j = 0; j <= mc; j++) {
            dp[j][!(i & 1)] = max(dp[j][!(i & 1)], dp[j][i & 1]);
            if(j + v[i][0] <= mc && j + v[i][0] >= 0) {
                dp[j + v[i][0]][!(i & 1)] = max(dp[j + v[i][0]][!(i & 1)], dp[j][i & 1] + v[i][2]);
                ans = max(ans, dp[j + v[i][0]][!(i & 1)]);
            }
            ans = max({ans, dp[j][!(i & 1)], dp[j][i & 1]}); 
        }
    cout << ans << endl;
        
}

컴파일 시 표준 에러 (stderr) 메시지

clo.cpp: In function 'void setIO(std::string)':
clo.cpp:26:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     freopen((s+".in").c_str(),"r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:27:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     freopen((s+".out").c_str(),"w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...