제출 #1259681

#제출 시각아이디문제언어결과실행 시간메모리
1259681vietbachleonkroos2326Nile (IOI24_nile)C++20
17 / 100
37 ms8884 KiB
#include<bits/stdc++.h>
#define TIME (1.0* clock()/CLOCKS_PER_SEC)
#define pb push_back
#define eb emplace_back
#define id1 (id<<1)
#define id2 (id<<1)|1
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int>> 
#define vl vector<long long>
#define vll vector <pair<ll,ll>>
#define li pair<long long,int>
#define vil vector <pair<int,ll>>
#define db double
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define FOR(i, a, b) for (int i = (a); i <=(b); i++)
#define F0R(i, a) FOR(i, 0, a-1)
#define ROF(i, a, b) for (int i = (b); i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a-1)
#define rep(a) F0R(_, a)
#define each(a, x) for (auto &a : x)
#define ALL(x) (x).begin(),(x).end()
#define pq priority_queue <li, vector <li>, greater <li>> 
using namespace std;


vector<long long> calculate_costs(vector<int> W, vector<int> A, vector<int> B, vector<int> E) {
    int n = W.size();
    int q = E.size();
    vector<long long> res;

    vector<tuple<int, int, int, int>> vec;
    for (int i = 0; i < n; i++) {
        vec.emplace_back(W[i], A[i], B[i], i);
    }

    sort(vec.begin(), vec.end());

    vector<int> nW(n), nA(n), nB(n);
    for (int i = 0; i < n; i++) {
        auto [w, a, b, idx] = vec[i];
        nW[i] = w;
        nA[i] = a;
        nB[i] = b;
    }

    for (int D : E) {
        vector<long long> dp(n + 1, 0);
        dp[0] = 0;

        for (int i = 0; i < n; i++) {
            dp[i + 1] = dp[i] + nA[i];
            if (i > 0 && (nW[i] - nW[i - 1] <= D)) {
                dp[i + 1] = min(dp[i + 1], dp[i - 1] + nB[i] + nB[i - 1]);
            }
        }
        res.push_back(dp[n]);
        if(q>5){
          for(int j=1;j<q;j++) res.push_back(dp[n]);
          return res;
        }
    }

    return res;
}
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...