# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
494428 | SuckTinHock | Job Scheduling (IOI19_job) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
const ll MOD = 1e9 + 7;
const double PI = cos(-1);
const ll INF = 1e16;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll n;
struct node
{
ll p, w, t;
}A[200005];
bool cmp(node A, node B)
{
if (A.p == B.p)
{
return (double)(A.w / A.t) > (double)(B.w > B.t);
}
return A.p < B.p;
}
void xuly()
{
ll res = 0, pre = 0;
sort(A+1,A+n+1,cmp);
for (ll i = 1; i <= n; ++i)
{
pre += A[i].t;
res += pre * (A[i].w);
}
cout << res;
}
void nhap()
{
cin >> n;
for (ll i = 1; i <= n; ++i) cin >> A[i].p;
for (ll i = 1; i <= n; ++i) cin >> A[i].w;
for (ll i = 1; i <= n; ++i) cin >> A[i].t;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
//freopen("IJOB.INP","r",stdin);
//freopen("IJOB.OUT","w",stdout);
//int T; cin >> T;
//while (T--)
//{
nhap();
xuly();
//}
return 0;
}