답안 #706832

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
706832 2023-03-07T21:29:06 Z AdamGS Job Scheduling (IOI19_job) C++17
24 / 100
91 ms 49392 KB
#include "job.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=2e5+7;
vector<int>V[LIM];
ll dp[LIM], sumu[LIM], sumczas[LIM], n;
bool srt(pair<ll,ll>a, pair<ll,ll>b) {
    return a.st*b.nd-a.nd*b.st<0;
}
void DFS(int x) {
    ll a=sumczas[x];
    vector<pair<ll,ll>>P;
    for(auto i : V[x]) {
        DFS(i);
        P.pb({sumczas[i], sumu[i]});
        sumu[x]+=sumu[i];
        sumczas[x]+=sumczas[i];
        dp[x]+=dp[i];
    }
    sort(P.begin(), P.end(), srt);
    ll akt=0;
    rep(i, P.size()) {
        dp[x]+=P[i].nd*akt;
        akt+=P[i].st;
    }
    dp[x]+=a*sumu[x];
}
ll scheduling_cost(vector<int>P, vector<int>U, vector<int>D) {
    n=P.size();
    rep(i, n-1) V[P[i+1]].pb(i+1);
    rep(i, n) {
        sumu[i]=U[i];
        sumczas[i]=D[i];
    }
    DFS(0);
    return dp[0];
}

Compilation message

job.cpp: In function 'void DFS(int)':
job.cpp:5:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(a, b) for(int a = 0; a < (b); ++a)
      |                                    ^
job.cpp:28:5: note: in expansion of macro 'rep'
   28 |     rep(i, P.size()) {
      |     ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 5204 KB Output is correct
5 Correct 22 ms 16080 KB Output is correct
6 Correct 43 ms 27336 KB Output is correct
7 Correct 64 ms 38260 KB Output is correct
8 Correct 80 ms 49232 KB Output is correct
9 Correct 79 ms 49240 KB Output is correct
10 Correct 79 ms 49268 KB Output is correct
11 Correct 3 ms 4908 KB Output is correct
12 Correct 83 ms 49304 KB Output is correct
13 Correct 89 ms 49392 KB Output is correct
14 Correct 79 ms 49380 KB Output is correct
15 Correct 79 ms 49164 KB Output is correct
16 Correct 83 ms 49280 KB Output is correct
17 Correct 79 ms 49216 KB Output is correct
18 Correct 80 ms 49264 KB Output is correct
19 Correct 86 ms 49260 KB Output is correct
20 Correct 80 ms 49252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 72 ms 19340 KB Output is correct
5 Correct 81 ms 20616 KB Output is correct
6 Correct 73 ms 20624 KB Output is correct
7 Correct 73 ms 20628 KB Output is correct
8 Correct 74 ms 20612 KB Output is correct
9 Correct 74 ms 20608 KB Output is correct
10 Correct 71 ms 20540 KB Output is correct
11 Correct 72 ms 20612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 3 ms 4996 KB Output is correct
4 Correct 3 ms 5076 KB Output is correct
5 Correct 9 ms 5972 KB Output is correct
6 Correct 82 ms 19292 KB Output is correct
7 Correct 91 ms 19292 KB Output is correct
8 Correct 80 ms 19280 KB Output is correct
9 Correct 77 ms 19212 KB Output is correct
10 Correct 2 ms 4948 KB Output is correct
11 Correct 3 ms 5076 KB Output is correct
12 Correct 6 ms 5844 KB Output is correct
13 Correct 6 ms 5980 KB Output is correct
14 Correct 77 ms 19292 KB Output is correct
15 Correct 81 ms 19280 KB Output is correct
16 Correct 81 ms 19332 KB Output is correct
17 Correct 79 ms 19240 KB Output is correct
18 Correct 78 ms 19492 KB Output is correct
19 Correct 77 ms 19280 KB Output is correct
20 Correct 79 ms 19288 KB Output is correct
21 Correct 76 ms 19272 KB Output is correct
22 Correct 79 ms 19288 KB Output is correct
23 Correct 79 ms 19384 KB Output is correct
24 Correct 78 ms 19292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4948 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Incorrect 2 ms 4948 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 5204 KB Output is correct
5 Correct 22 ms 16080 KB Output is correct
6 Correct 43 ms 27336 KB Output is correct
7 Correct 64 ms 38260 KB Output is correct
8 Correct 80 ms 49232 KB Output is correct
9 Correct 79 ms 49240 KB Output is correct
10 Correct 79 ms 49268 KB Output is correct
11 Correct 3 ms 4908 KB Output is correct
12 Correct 83 ms 49304 KB Output is correct
13 Correct 89 ms 49392 KB Output is correct
14 Correct 79 ms 49380 KB Output is correct
15 Correct 79 ms 49164 KB Output is correct
16 Correct 83 ms 49280 KB Output is correct
17 Correct 79 ms 49216 KB Output is correct
18 Correct 80 ms 49264 KB Output is correct
19 Correct 86 ms 49260 KB Output is correct
20 Correct 80 ms 49252 KB Output is correct
21 Correct 3 ms 4948 KB Output is correct
22 Correct 2 ms 4948 KB Output is correct
23 Correct 3 ms 4948 KB Output is correct
24 Correct 72 ms 19340 KB Output is correct
25 Correct 81 ms 20616 KB Output is correct
26 Correct 73 ms 20624 KB Output is correct
27 Correct 73 ms 20628 KB Output is correct
28 Correct 74 ms 20612 KB Output is correct
29 Correct 74 ms 20608 KB Output is correct
30 Correct 71 ms 20540 KB Output is correct
31 Correct 72 ms 20612 KB Output is correct
32 Correct 2 ms 4948 KB Output is correct
33 Correct 2 ms 4948 KB Output is correct
34 Correct 3 ms 4996 KB Output is correct
35 Correct 3 ms 5076 KB Output is correct
36 Correct 9 ms 5972 KB Output is correct
37 Correct 82 ms 19292 KB Output is correct
38 Correct 91 ms 19292 KB Output is correct
39 Correct 80 ms 19280 KB Output is correct
40 Correct 77 ms 19212 KB Output is correct
41 Correct 2 ms 4948 KB Output is correct
42 Correct 3 ms 5076 KB Output is correct
43 Correct 6 ms 5844 KB Output is correct
44 Correct 6 ms 5980 KB Output is correct
45 Correct 77 ms 19292 KB Output is correct
46 Correct 81 ms 19280 KB Output is correct
47 Correct 81 ms 19332 KB Output is correct
48 Correct 79 ms 19240 KB Output is correct
49 Correct 78 ms 19492 KB Output is correct
50 Correct 77 ms 19280 KB Output is correct
51 Correct 79 ms 19288 KB Output is correct
52 Correct 76 ms 19272 KB Output is correct
53 Correct 79 ms 19288 KB Output is correct
54 Correct 79 ms 19384 KB Output is correct
55 Correct 78 ms 19292 KB Output is correct
56 Incorrect 2 ms 4948 KB Output isn't correct
57 Halted 0 ms 0 KB -