Submission #1060767

# Submission time Handle Problem Language Result Execution time Memory
1060767 2024-08-15T22:19:31 Z boyliguanhan Job Scheduling (IOI19_job) C++17
0 / 100
1 ms 348 KB
#include "job.h"
#include <bits/stdc++.h>
using namespace std;
struct DATA{
    int timetaken,value,i;
    DATA(int u,int d,int ind){
        value=u,timetaken=d,i=ind;
    }
    DATA(){
        timetaken=1e9;
        value=1;
    }
    friend bool operator<(const DATA &a,const DATA&b){
        return a.timetaken*b.value<
                b.timetaken*a.value;
    }
};
long long scheduling_cost(std::vector<int> p, std::vector<int> u, std::vector<int> d) {
    int N=p.size();
    vector<int>ord,deg(N);
    priority_queue<DATA>pq;
    for(int i=1;i<N;i++)
        deg[p[i]]++;
    for(int i=0;i<N;i++) if(!deg[i])
        pq.push(DATA(u[i],d[i],i));
    while(pq.size()){
        int K=pq.top().i;
        pq.pop();
        if(!--deg[p[K]])
            pq.push(DATA(u[p[K]],d[p[K]],p[K]));
        ord.push_back(K);
    }
    reverse(ord.begin(),ord.end());
    long long curtime=0,ans=0;
    for(auto i:ord)
        ans+=u[i]*(curtime+=d[i]);
    return ans;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -