답안 #210870

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
210870 2020-03-18T23:58:50 Z HNO2 Job Scheduling (IOI19_job) C++17
24 / 100
300 ms 36560 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn=2e5+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
//#define int ll

#ifdef HNO2
#define IOS
#else
#include <job.h>
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

vector<int> G[maxn];
ll cost[maxn],t[maxn];
ll summ[maxn];

void dfs(int now,int p)
{
    summ[now]+=cost[now];
    for (int i:G[now])
        if (i!=p) dfs(i,now),summ[now]+=summ[i];
}

struct frac
{
    int x,y,id;
    frac():x(0),y(0),id(0){}
    frac(int _x,int _y,int _id):x(_x),y(_y),id(_id){}
    bool operator<(const frac &rhs)const
    {
        return x*1ll*rhs.y<y*1ll*rhs.x;
    }
    bool operator>(const frac &rhs)const
    {
        return x*1ll*rhs.y>y*1ll*rhs.x;
    }
};

long long scheduling_cost(std::vector<int> P, std::vector<int> U, std::vector<int> D)
{
    int n=sz(P);
    for (int i=1;i<n;i++)
        G[P[i]+1].pb(i+1);
    for (int i=1;i<=n;i++) t[i]=D[i-1],cost[i]=U[i-1];

    dfs(1,-1);

    priority_queue<frac> pq;
    pq.push(frac(summ[1],t[1],1));

    ll sum=0,ret=0;

    while (!pq.empty())
    {
        frac now=pq.top();
        pq.pop();
        sum+=t[now.id];
        ret+=cost[now.id]*sum;
        for (int i:G[now.id])
            pq.push(frac(summ[i],t[i],i));
    }
    return ret;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 4984 KB Output is correct
2 Correct 9 ms 4988 KB Output is correct
3 Correct 11 ms 5112 KB Output is correct
4 Correct 9 ms 5112 KB Output is correct
5 Correct 45 ms 12092 KB Output is correct
6 Correct 76 ms 19064 KB Output is correct
7 Correct 122 ms 26212 KB Output is correct
8 Correct 159 ms 36560 KB Output is correct
9 Correct 156 ms 36344 KB Output is correct
10 Correct 151 ms 36316 KB Output is correct
11 Correct 11 ms 5112 KB Output is correct
12 Correct 152 ms 36328 KB Output is correct
13 Correct 151 ms 36480 KB Output is correct
14 Correct 153 ms 36472 KB Output is correct
15 Correct 158 ms 36344 KB Output is correct
16 Correct 162 ms 36444 KB Output is correct
17 Correct 161 ms 36472 KB Output is correct
18 Correct 162 ms 36316 KB Output is correct
19 Correct 154 ms 36344 KB Output is correct
20 Correct 155 ms 36344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 4984 KB Output is correct
2 Correct 10 ms 5140 KB Output is correct
3 Correct 10 ms 4984 KB Output is correct
4 Correct 193 ms 19048 KB Output is correct
5 Correct 207 ms 20812 KB Output is correct
6 Correct 208 ms 20840 KB Output is correct
7 Correct 210 ms 20856 KB Output is correct
8 Correct 205 ms 20740 KB Output is correct
9 Correct 190 ms 20840 KB Output is correct
10 Correct 198 ms 20844 KB Output is correct
11 Correct 191 ms 20840 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 4984 KB Output is correct
2 Correct 11 ms 5140 KB Output is correct
3 Correct 9 ms 4984 KB Output is correct
4 Correct 10 ms 5112 KB Output is correct
5 Correct 17 ms 5880 KB Output is correct
6 Correct 216 ms 19304 KB Output is correct
7 Correct 227 ms 21352 KB Output is correct
8 Correct 200 ms 21352 KB Output is correct
9 Correct 210 ms 21352 KB Output is correct
10 Correct 9 ms 5112 KB Output is correct
11 Correct 11 ms 5200 KB Output is correct
12 Correct 18 ms 6008 KB Output is correct
13 Correct 18 ms 6008 KB Output is correct
14 Correct 211 ms 21352 KB Output is correct
15 Correct 300 ms 21480 KB Output is correct
16 Correct 212 ms 21344 KB Output is correct
17 Correct 236 ms 21356 KB Output is correct
18 Correct 203 ms 21352 KB Output is correct
19 Correct 249 ms 21460 KB Output is correct
20 Correct 202 ms 21352 KB Output is correct
21 Correct 212 ms 21352 KB Output is correct
22 Correct 203 ms 21352 KB Output is correct
23 Correct 207 ms 21480 KB Output is correct
24 Correct 207 ms 21368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 4984 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 4984 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 4984 KB Output is correct
2 Correct 9 ms 4988 KB Output is correct
3 Correct 11 ms 5112 KB Output is correct
4 Correct 9 ms 5112 KB Output is correct
5 Correct 45 ms 12092 KB Output is correct
6 Correct 76 ms 19064 KB Output is correct
7 Correct 122 ms 26212 KB Output is correct
8 Correct 159 ms 36560 KB Output is correct
9 Correct 156 ms 36344 KB Output is correct
10 Correct 151 ms 36316 KB Output is correct
11 Correct 11 ms 5112 KB Output is correct
12 Correct 152 ms 36328 KB Output is correct
13 Correct 151 ms 36480 KB Output is correct
14 Correct 153 ms 36472 KB Output is correct
15 Correct 158 ms 36344 KB Output is correct
16 Correct 162 ms 36444 KB Output is correct
17 Correct 161 ms 36472 KB Output is correct
18 Correct 162 ms 36316 KB Output is correct
19 Correct 154 ms 36344 KB Output is correct
20 Correct 155 ms 36344 KB Output is correct
21 Correct 10 ms 4984 KB Output is correct
22 Correct 10 ms 5140 KB Output is correct
23 Correct 10 ms 4984 KB Output is correct
24 Correct 193 ms 19048 KB Output is correct
25 Correct 207 ms 20812 KB Output is correct
26 Correct 208 ms 20840 KB Output is correct
27 Correct 210 ms 20856 KB Output is correct
28 Correct 205 ms 20740 KB Output is correct
29 Correct 190 ms 20840 KB Output is correct
30 Correct 198 ms 20844 KB Output is correct
31 Correct 191 ms 20840 KB Output is correct
32 Correct 10 ms 4984 KB Output is correct
33 Correct 11 ms 5140 KB Output is correct
34 Correct 9 ms 4984 KB Output is correct
35 Correct 10 ms 5112 KB Output is correct
36 Correct 17 ms 5880 KB Output is correct
37 Correct 216 ms 19304 KB Output is correct
38 Correct 227 ms 21352 KB Output is correct
39 Correct 200 ms 21352 KB Output is correct
40 Correct 210 ms 21352 KB Output is correct
41 Correct 9 ms 5112 KB Output is correct
42 Correct 11 ms 5200 KB Output is correct
43 Correct 18 ms 6008 KB Output is correct
44 Correct 18 ms 6008 KB Output is correct
45 Correct 211 ms 21352 KB Output is correct
46 Correct 300 ms 21480 KB Output is correct
47 Correct 212 ms 21344 KB Output is correct
48 Correct 236 ms 21356 KB Output is correct
49 Correct 203 ms 21352 KB Output is correct
50 Correct 249 ms 21460 KB Output is correct
51 Correct 202 ms 21352 KB Output is correct
52 Correct 212 ms 21352 KB Output is correct
53 Correct 203 ms 21352 KB Output is correct
54 Correct 207 ms 21480 KB Output is correct
55 Correct 207 ms 21368 KB Output is correct
56 Incorrect 9 ms 4984 KB Output isn't correct
57 Halted 0 ms 0 KB -