답안 #254302

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
254302 2020-07-29T20:01:26 Z MarcoMeijer Cloud Computing (CEOI18_clo) C++14
18 / 100
26 ms 52224 KB
#include <bits/stdc++.h>
using namespace std;

// macros
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<lll> vlll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define FOR(a,b) for(auto& a : b)
#define all(a) a.begin(), a.end()
#define INF 1e18
#define EPS 1e-9
#define pb push_back
#define popb pop_back
#define fi first
#define se second
#define sz size()

// input
template<class T> void IN(T& x) {cin >> x;}
template<class H, class... T> void IN(H& h, T&... t) {IN(h); IN(t...); }

// output
template<class T1, class T2> void OUT(const pair<T1,T2>& x);
template<class T> void OUT(const T& x) {cout << x;}
template<class H, class... T> void OUT(const H& h, const T&... t) {OUT(h); OUT(t...); }
template<class T1, class T2> void OUT(const pair<T1,T2>& x) {OUT(x.fi," ",x.se);}
template<class... T> void OUTL(const T&... t) {OUT(t..., "\n"); }

//===================//
//  Added libraries  //
//===================//

//===================//
//end added libraries//
//===================//

void program();
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    program();
}


//===================//
//   begin program   //
//===================//

const int MX = 400;
ll n, m;
ll c[MX], f[MX], v[MX];
ll C[MX], F[MX], V[MX];
ll sa[MX], SA[MX];

ll dp[MX][MX][104];

ll DP(ll i, ll j, ll k) {
    if(i < 0) return 0;
    if(j < 0) return 0;
    return dp[i][j][k];
}

void program() {
    IN(n);
    RE(i,n) IN(c[i], f[i], v[i]);
    IN(m);
    RE(i,m) IN(C[i], F[i], V[i]);

    RE(i,n) sa[i]=i;
    sort(sa,sa+n,[](int i, int j) {
        return f[i]<f[j];
    });
    RE(i,m) SA[i]=i;
    sort(SA,SA+m,[](int i, int j) {
        return F[i]<F[j];
    });

    RE(i,n+1) RE(j,m) RE(k,20) {
        ll ans = DP(i,j-1,k); // dont give customer j her cores
        ans = max(ans,DP(i-1,j,k)); // dont buy computer i

        // give customer j her cores
        if(k >= C[SA[j]]) {
            ans = max(ans, DP(i,j-1,k-C[SA[j]])+V[SA[j]]);
        }

        // buy computer i
        if(i != 0 && f[sa[i-1]] >= F[SA[j]]) {
            ans = max(ans, DP(i-1,j,k+c[sa[i-1]])-v[sa[i-1]]);
        }

        dp[i][j][k] = ans;
    }

    OUTL(dp[n][m-1][0]);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 1152 KB Output is correct
4 Incorrect 1 ms 1664 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 1280 KB Output is correct
4 Incorrect 1 ms 1280 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 640 KB Output is correct
2 Correct 0 ms 640 KB Output is correct
3 Correct 4 ms 7168 KB Output is correct
4 Correct 4 ms 7168 KB Output is correct
5 Correct 13 ms 26624 KB Output is correct
6 Correct 14 ms 26624 KB Output is correct
7 Correct 25 ms 52220 KB Output is correct
8 Correct 26 ms 52224 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Incorrect 1 ms 512 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 3 ms 5376 KB Output is correct
3 Incorrect 2 ms 2304 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 1152 KB Output is correct
4 Incorrect 1 ms 1664 KB Output isn't correct
5 Halted 0 ms 0 KB -