답안 #314844

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
314844 2020-10-21T13:25:19 Z blue Job Scheduling (IOI19_job) C++17
컴파일 오류
0 ms 0 KB
#include "job.h"
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

struct job
{
    long long u;
    long long d;
    vector<int> children;
};

bool operator < (job A, job B)
{
    return A.u*B.d > B.u*A.d;
}

long long scheduling_cost(vector<int> p, vector<int> u, vector<int> d)
{
    long long res = 0;
    int n = p.size();

    job J[n];
    vector<int> v;
    for(int i = 0; i < n; i++)
    {
        J[i] = job{u[i], d[i], v};
        if(i > 0) J[p[i]].children.push_back(i);
    }

    long long t = 0;

    set<job> S;
    S.insert(J[0]);

    job j;

    while(!S.empty())
    {
        j = S.front();
        S.erase(S.front());
        for(int k: j.children) S.insert(J[k]);
        t += j.d;
        res += t * j.u;
    }

	return res;
}

Compilation message

job.cpp: In function 'long long int scheduling_cost(std::vector<int>, std::vector<int>, std::vector<int>)':
job.cpp:41:15: error: 'class std::set<job>' has no member named 'front'
   41 |         j = S.front();
      |               ^~~~~
job.cpp:42:19: error: 'class std::set<job>' has no member named 'front'
   42 |         S.erase(S.front());
      |                   ^~~~~