Submission #148033

# Submission time Handle Problem Language Result Execution time Memory
148033 2019-08-31T11:48:23 Z neki Job Scheduling (IOI19_job) C++14
Compilation error
0 ms 0 KB
//#include "job.h"
#include <bits/stdc++.h>
using namespace std;
#define maxn 200100
#define loop(i, a, b ) for(int i=a;i<b;i++)
typedef long long ll;
 
struct temp{
    ll a, t, sa, st;vector<ll> chs;
    bool operator<(const temp &dr) const {
        return sa*dr.st<dr.sa*st;
    }
};
temp ts[maxn];
 
 
ll scheduling_cost(vector<int> p, vector<int> a, vector<int> t) {
    ll n=p.size();
    loop(i,0, n) ts[i].a=a[i], ts[i].t=t[i], ts[i].sa=ts[i].a, ts[i].st=ts[i].t;
    loop(i, 0, n) if(p[i]!=-1) ts[p[i]].sa+=ts[i].sa, ts[p[i]].st+=ts[i].st, ts[p[i]].chs.push_back(i);
    priority_queue<temp> pq;pq.push(ts[0]);
    ll ct=0, ans=0;
    while(pq.size()){
        auto v=pq.top();pq.pop();
        ct+=v.t;
        ans+=ct * v.a;
        for(auto&& i: v.chs) pq.push(ts[i]);
    }
    return ans;
}

int main(){
    cout << scheduling_cost({-1, 0, 0}, {5, 2, 5}, {3, 4, 1});
}

Compilation message

/tmp/ccUnSBg0.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cc0FMwpT.o:job.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status