QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#375381#4089. 회의실bachbeo2007Compile Error//C++231.7kb2024-04-03 10:01:062024-04-03 10:01:07

Judging History

你现在查看的是最新测评结果

  • [2024-04-03 10:01:07]
  • 评测
  • [2024-04-03 10:01:06]
  • 提交

answer

#include "meeting.h"
#include<bits/stdc++.h>
using namespace std;

using i32 = int;
#define int long long
#define pii pair<int,int>
#define piii pair<pii,int>
#define fi first
#define se second
const int maxn = 5005;
const int inf = 1e18;
int dp[maxn];
vector<pii> lt[maxn],rt[maxn];

int min_charge(int K,vector<i32> S,vector<i32> E,vector<i32> W){
    int N=(int)S.size();
    vector<int> com;
    for(int i=0;i<N;i++){
        com.push_back(S[i]);
        com.push_back(E[i]+1);
    }
    sort(com.begin(),com.end());
    com.erase(unique(com.begin(),com.end()),com.end());
    for(int i=0;i<N;i++){
        S[i]=lower_bound(com.begin(),com.end(),S[i])-com.begin()+1;
        E[i]=lower_bound(com.begin(),com.end(),E[i]+1)-com.begin();
        lt[S[i]].push_back({E[i],W[i]});
        rt[E[i]].push_back({S[i],W[i]});
    }
    int sz=(int)com.size();
    for(int i=1;i<=sz;i++){
        int total=0,sum=0;
        priority_queue<int,vector<int>,greater<int>> pq;
        dp[i]=inf;
        for(int j=i;j>=1;j--){
            for(auto [x,val]:rt[j]) total+=val;
            for(auto [x,val]:lt[j]){
                if(x<=i){
                    sum+=val;
                    pq.push(val);
                    if((int)pq.size()>K) sum-=pq.top(),pq.pop();
                }
            }
            dp[i]=min(dp[i],dp[j-1]+total-sum);
        }
    }
    return dp[sz];
}

#undef int
/*
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int N,K;cin >> N >> K;
    vector<int> S(N),E(N),W(N);
    for(int i=0;i<N;i++) cin >> S[i] >> E[i] >> W[i];
    cout << min_charge(K,S,E,W) << '\n';
}
*/

Details

/usr/bin/ld: /tmp/ccoFlIIP.o: in function `main':
implementer.cpp:(.text.startup+0x3c4): undefined reference to `min_charge(int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status