제출 #1337130

#제출 시각아이디문제언어결과실행 시간메모리
1337130Rafael_AugustoCloud Computing (CEOI18_clo)C++20
100 / 100
233 ms1316 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back
#define f first
#define s second
#define get(i, v) get<i>(v)
#define all(v) v.begin(), v.end()
#define dbg(v) cerr << #v << " = " << v << "\n"
#define fall(i, s, n) for(int i=s; i<n; i++)
#define rfall(i, s, n) for(int i=s; i>=n; i--)

typedef pair<int, int> pii;
typedef tuple<int, int, int> trio;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void setIO(string name){
    freopen((name+".in").c_str(), "r", stdin);
    freopen((name+".out").c_str(), "w", stdout);
}

const int MAXN = 1e5+7;

int dp[MAXN];

int32_t main(){
    ios::sync_with_stdio(0); cin.tie(0);
    
    int n; cin >> n;

    vector<trio> v(n);

    for(auto& [f, c, vi] : v) cin >> c >> f >> vi;

    sort(all(v)), reverse(all(v));

    fall(i, 0, MAXN) dp[i] = -1e15;
    dp[0]=0;

    int m; cin >> m;

    vector<trio> v2(m);

    for(auto& [f, c, vi] : v2) cin >> c >> f >> vi;

    sort(all(v2)), reverse(all(v2));

    int p=0;

    for(auto [f, ci, vi] : v2){
        while(p < n && get(0, v[p]) >= f){
            auto [fj, cj, vj]=v[p];

            rfall(k, MAXN-1, cj) dp[k] = max(dp[k], dp[k-cj]-vj);

            p++;
        }

        fall(k, 0, MAXN-ci) dp[k] = max(dp[k], dp[k+ci]+vi);
    }

    int mx=0;

    fall(i, 0, MAXN) mx = max(mx, dp[i]);

    cout << mx << "\n";
}

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

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