답안 #202614

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
202614 2020-02-17T09:46:55 Z anonymous Job Scheduling (IOI19_job) C++14
24 / 100
185 ms 21468 KB
#include "job.h"
#include <vector>
#include<queue>
#include<utility>
#include<iostream>
#define LL long long
#define MAXN 300005
using namespace std;
struct Job {LL wt, t, id;};
class CompareClass {
public:
    bool operator() (Job a, Job b) {
        return(a.wt*b.t > a.t*b.wt); //wt, time
    }
};
int chd[MAXN], N;
priority_queue<Job ,vector<Job>, CompareClass> PQ;
vector<Job> Order;
LL scheduling_cost(std::vector<int> p, std::vector<int> u, std::vector<int> d) {
	N=p.size();
	for(int i=1; i<N; i++) {
        chd[p[i]]++;
	}
	for (int i=0; i<N; i++) {
        if (!chd[i]) {
            PQ.push(Job {u[i], d[i], i});
        }
	}
	while (Order.size() < N) {
        Job opt = PQ.top();
        PQ.pop();
        Order.push_back(opt);
        if (opt.id == 0) {break;}
        chd[p[opt.id]]--;
        if (!chd[p[opt.id]]) {
            PQ.push(Job {u[p[opt.id]], d[p[opt.id]], p[opt.id]});
        }
	}
	LL ans=0, time=0;
	for (int i=N-1; i>=0; i--) {
        time+=Order[i].t;
        ans+=Order[i].wt*time;
	}
	return(ans);
}

Compilation message

job.cpp: In function 'long long int scheduling_cost(std::vector<int>, std::vector<int>, std::vector<int>)':
job.cpp:29:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while (Order.size() < N) {
         ~~~~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 30 ms 4184 KB Output is correct
6 Correct 59 ms 7788 KB Output is correct
7 Correct 81 ms 13028 KB Output is correct
8 Correct 113 ms 15204 KB Output is correct
9 Correct 106 ms 15336 KB Output is correct
10 Correct 115 ms 15332 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 108 ms 15256 KB Output is correct
13 Correct 117 ms 15240 KB Output is correct
14 Correct 107 ms 15332 KB Output is correct
15 Correct 109 ms 15332 KB Output is correct
16 Correct 110 ms 15332 KB Output is correct
17 Correct 115 ms 15336 KB Output is correct
18 Correct 108 ms 15464 KB Output is correct
19 Correct 110 ms 15332 KB Output is correct
20 Correct 109 ms 15332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 368 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 157 ms 20700 KB Output is correct
5 Correct 152 ms 20700 KB Output is correct
6 Correct 155 ms 20704 KB Output is correct
7 Correct 154 ms 20700 KB Output is correct
8 Correct 159 ms 20704 KB Output is correct
9 Correct 159 ms 20700 KB Output is correct
10 Correct 153 ms 20700 KB Output is correct
11 Correct 163 ms 20872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 11 ms 1528 KB Output is correct
6 Correct 168 ms 21232 KB Output is correct
7 Correct 164 ms 21320 KB Output is correct
8 Correct 174 ms 21356 KB Output is correct
9 Correct 176 ms 21340 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 6 ms 504 KB Output is correct
12 Correct 10 ms 1400 KB Output is correct
13 Correct 11 ms 1524 KB Output is correct
14 Correct 177 ms 21340 KB Output is correct
15 Correct 185 ms 21464 KB Output is correct
16 Correct 171 ms 21212 KB Output is correct
17 Correct 160 ms 21340 KB Output is correct
18 Correct 165 ms 21468 KB Output is correct
19 Correct 168 ms 21340 KB Output is correct
20 Correct 172 ms 21212 KB Output is correct
21 Correct 176 ms 21212 KB Output is correct
22 Correct 176 ms 21340 KB Output is correct
23 Correct 176 ms 21304 KB Output is correct
24 Correct 159 ms 21340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 30 ms 4184 KB Output is correct
6 Correct 59 ms 7788 KB Output is correct
7 Correct 81 ms 13028 KB Output is correct
8 Correct 113 ms 15204 KB Output is correct
9 Correct 106 ms 15336 KB Output is correct
10 Correct 115 ms 15332 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 108 ms 15256 KB Output is correct
13 Correct 117 ms 15240 KB Output is correct
14 Correct 107 ms 15332 KB Output is correct
15 Correct 109 ms 15332 KB Output is correct
16 Correct 110 ms 15332 KB Output is correct
17 Correct 115 ms 15336 KB Output is correct
18 Correct 108 ms 15464 KB Output is correct
19 Correct 110 ms 15332 KB Output is correct
20 Correct 109 ms 15332 KB Output is correct
21 Correct 5 ms 368 KB Output is correct
22 Correct 5 ms 376 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 157 ms 20700 KB Output is correct
25 Correct 152 ms 20700 KB Output is correct
26 Correct 155 ms 20704 KB Output is correct
27 Correct 154 ms 20700 KB Output is correct
28 Correct 159 ms 20704 KB Output is correct
29 Correct 159 ms 20700 KB Output is correct
30 Correct 153 ms 20700 KB Output is correct
31 Correct 163 ms 20872 KB Output is correct
32 Correct 5 ms 376 KB Output is correct
33 Correct 5 ms 256 KB Output is correct
34 Correct 5 ms 376 KB Output is correct
35 Correct 5 ms 376 KB Output is correct
36 Correct 11 ms 1528 KB Output is correct
37 Correct 168 ms 21232 KB Output is correct
38 Correct 164 ms 21320 KB Output is correct
39 Correct 174 ms 21356 KB Output is correct
40 Correct 176 ms 21340 KB Output is correct
41 Correct 5 ms 376 KB Output is correct
42 Correct 6 ms 504 KB Output is correct
43 Correct 10 ms 1400 KB Output is correct
44 Correct 11 ms 1524 KB Output is correct
45 Correct 177 ms 21340 KB Output is correct
46 Correct 185 ms 21464 KB Output is correct
47 Correct 171 ms 21212 KB Output is correct
48 Correct 160 ms 21340 KB Output is correct
49 Correct 165 ms 21468 KB Output is correct
50 Correct 168 ms 21340 KB Output is correct
51 Correct 172 ms 21212 KB Output is correct
52 Correct 176 ms 21212 KB Output is correct
53 Correct 176 ms 21340 KB Output is correct
54 Correct 176 ms 21304 KB Output is correct
55 Correct 159 ms 21340 KB Output is correct
56 Incorrect 5 ms 256 KB Output isn't correct
57 Halted 0 ms 0 KB -