Submission #211051

#TimeUsernameProblemLanguageResultExecution timeMemory
211051wiwihoJob Scheduling (IOI19_job)C++14
24 / 100
206 ms18692 KiB
//#define NDEBUG #include "job.h" #include <bits/stdc++.h> #include <bits/extc++.h> #define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define iter(a) a.begin(), a.end() #define riter(a) a.rbegin(), a.rend() #define lsort(a) sort(iter(a)) #define gsort(a) sort(riter(a)) #define mp(a, b) make_pair(a, b) #define pb(a) push_back(a) #define eb(a) emplace_back(a) #define pf(a) push_front(a) #define pob pop_back() #define pof pop_front() #define F first #define S second #define printv(a, b) {bool pvaspace=false; \ for(auto pva : a){ \ if(pvaspace) b << " "; pvaspace=true;\ b << pva;\ }\ b << "\n";} #define pii pair<int, int> #define pll pair<ll, ll> #define tiii tuple<int, int, int> #define mt make_tuple #define gt(t, i) get<i>(t) #define iceil(a, b) ((a) / (b) + !!((a) % (b))) //#define TEST typedef long long ll; typedef unsigned long long ull; using namespace std; using namespace __gnu_pbds; const ll MOD = 1000000007; const ll MAX = 2147483647; template<typename A, typename B> ostream& operator<<(ostream& o, pair<A, B> p){ return o << '(' << p.F << ',' << p.S << ')'; } struct comp{ bool operator()(pair<pll, ll> a, pair<pll, ll> b){ return a.F.F * b.F.S > b.F.F * a.F.S; } }; ll scheduling_cost(vector<int> p, vector<int> u, vector<int> d){ int n = p.size(); vector<vector<int>> g(n); for(int i = 1; i < n; i++) g[p[i]].eb(i); std::priority_queue<pair<pll, ll>, vector<pair<pll, ll>>, comp> pq; pq.push(mp(mp(d[0], u[0]), 0LL)); ll ans = 0; ll tm = 0; while(!pq.empty()){ auto now = pq.top(); pq.pop(); tm += now.F.F; ans += tm * now.F.S; for(int i : g[now.S]) pq.push(mp(mp(d[i], u[i]), i)); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...