제출 #437763

#제출 시각아이디문제언어결과실행 시간메모리
437763definitelynotmeeCloud Computing (CEOI18_clo)C++98
0 / 100
2 ms204 KiB
#include <bits/stdc++.h>
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INFL = (1LL<<62)-1;
const int INF = (1<<30)-1;
const int MOD = 1e9 + 7;
const int MAXN = 1e6+1;

struct specs{
    int core, speed, value;
    inline bool operator<(specs b) const{
        return speed > b.speed;
    }
};

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin >> n;
    vector<specs> comp(n);
    bool c1 = 1, s1 = 1, v1 = 1;
    int corecount = 0;
    for(int i = 0; i < n; i++)
        cin >> comp[i].core >> comp[i].speed >> comp[i].value, corecount+=comp[i].core,c1 = c1&&(comp[i].core==1), s1 = s1&&(comp[i].speed==1),v1 = v1&&(comp[i].value==1);
    int m;
    cin >> m;
    vector<specs> order(m);
    for(int i = 0; i < m; i++)
        cin >> order[i].core >> order[i].speed >> order[i].value, c1 = c1&&(order[i].core==1), s1 = s1&&(order[i].speed==1),v1 = v1&&(order[i].value==1);
    sort(comp.begin(),comp.end());
    sort(order.begin(),order.end());

    if(n<=15){
        int resp = 0;
        for(int mask = 0; mask < (1<<n); mask++){
            vector<int>dp(corecount+1,0);
            int gasto = 0;
            for(int i = 0; i < n; i++)
                if(mask&(1<<i))
                    gasto+=comp[i].value;
            
            int ptr = 0;
            int available = 0;
            for(int i = 0; i < m; i++){
                while(ptr < n && comp[ptr].speed>=order[i].speed){
                    if(mask&(1<<ptr))
                        available+=comp[ptr].core;
                    ptr++;
                }
                for(int i = 0; i <= available; i++){
                    if(i-order[i].core>=0){
                        dp[i] = max(dp[i],dp[i-order[i].core] + order[i].value);
                    }
                }
            }
            resp = max(resp,dp[available]);
        }
        cout << resp << '\n';
    } else if(m <= 15){

    } else if(c1){

    } else if(s1){

    } else if(v1){

    }
    
    return 0;

}
#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...