답안 #906296

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
906296 2024-01-13T23:46:30 Z vjudge1 Job Scheduling (IOI19_job) C++17
12 / 100
62 ms 5852 KB
#include "job.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define endl '\n'
#define K first
#define V second

using namespace std;
using namespace __gnu_pbds;


template<typename T>
ostream_iterator<T> oit(const string &s = " "){
    return ostream_iterator<T>(cout,s.c_str());
}

struct chash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

template<typename T, typename U> using pb_map = gp_hash_table<T, U, chash>;
template<typename T> using pb_set = gp_hash_table<T, null_type, chash>;

typedef long long ll;
typedef long double ld;

typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;

constexpr ll NN = 2e5;
constexpr ll M = 1000000007;



long long scheduling_cost(std::vector<int> p, std::vector<int> u, std::vector<int> d) {
	ll ans = 0;
    int n = (int)p.size();
    bool case1 = true,case2 = true;


    for(int i=1;i<n;i++){
        case1 &= p[i]==i-1;

        case2 &= p[i]==0;
        case2 &= d[i]==1;
    }

    if(case1){
        ll time = 0;
        for(int i=0;i<n;i++){
            time += d[i];
            ans += time*u[i];
        }
        return ans;
    }

    if(case2){
        ll time = d[0];
        ans += time*u[0];

        vi ord(n-1); iota(ord.begin(),ord.end(),1);

        sort(ord.begin(),ord.end(), [&](int i,int j){
            long long val1 = (u[i]*d[i]) + u[j]*(d[i]+d[j]);
            long long val2 = (u[j]*d[j]) + u[i]*(d[j]+d[i]);
            return val1 < val2;
        });

        for(int i : ord){
            time += d[i];
            ans += time*u[i];
        }

        return ans;
    }

    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 13 ms 1604 KB Output is correct
6 Correct 22 ms 2652 KB Output is correct
7 Correct 33 ms 3924 KB Output is correct
8 Correct 47 ms 4944 KB Output is correct
9 Correct 43 ms 5076 KB Output is correct
10 Correct 46 ms 4948 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 54 ms 5156 KB Output is correct
13 Correct 42 ms 4956 KB Output is correct
14 Correct 46 ms 5080 KB Output is correct
15 Correct 45 ms 5112 KB Output is correct
16 Correct 44 ms 4944 KB Output is correct
17 Correct 43 ms 5080 KB Output is correct
18 Correct 53 ms 5080 KB Output is correct
19 Correct 43 ms 5076 KB Output is correct
20 Correct 44 ms 4944 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 62 ms 5812 KB Output is correct
5 Correct 61 ms 5712 KB Output is correct
6 Correct 61 ms 5720 KB Output is correct
7 Correct 61 ms 5712 KB Output is correct
8 Correct 62 ms 5848 KB Output is correct
9 Correct 62 ms 5852 KB Output is correct
10 Correct 61 ms 5712 KB Output is correct
11 Correct 62 ms 5712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 13 ms 1604 KB Output is correct
6 Correct 22 ms 2652 KB Output is correct
7 Correct 33 ms 3924 KB Output is correct
8 Correct 47 ms 4944 KB Output is correct
9 Correct 43 ms 5076 KB Output is correct
10 Correct 46 ms 4948 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 54 ms 5156 KB Output is correct
13 Correct 42 ms 4956 KB Output is correct
14 Correct 46 ms 5080 KB Output is correct
15 Correct 45 ms 5112 KB Output is correct
16 Correct 44 ms 4944 KB Output is correct
17 Correct 43 ms 5080 KB Output is correct
18 Correct 53 ms 5080 KB Output is correct
19 Correct 43 ms 5076 KB Output is correct
20 Correct 44 ms 4944 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 62 ms 5812 KB Output is correct
25 Correct 61 ms 5712 KB Output is correct
26 Correct 61 ms 5720 KB Output is correct
27 Correct 61 ms 5712 KB Output is correct
28 Correct 62 ms 5848 KB Output is correct
29 Correct 62 ms 5852 KB Output is correct
30 Correct 61 ms 5712 KB Output is correct
31 Correct 62 ms 5712 KB Output is correct
32 Incorrect 0 ms 344 KB Output isn't correct
33 Halted 0 ms 0 KB -