# 題目
AP325 Q-4-16. 賺錢與罰款
# 解題思路
目前沒東西...
# 程式碼
#include <bits/stdc++.h> | |
using namespace std; | |
#define N 100005 | |
struct money{ | |
int t,d; | |
}; | |
// 依工作時間排序 | |
bool cmp(money a,money b){ | |
return a.t<b.t; | |
} | |
int main(){ | |
int n; | |
long long all=0; | |
money td[N]; | |
cin>>n; | |
for(int i=0;i<n;i++) | |
cin>>td[i].t; | |
for(int i=0;i<n;i++) | |
cin>>td[i].d; | |
sort(td,td+n,cmp); | |
for(int i=0,now=0;i<n;i++){ | |
now+=td[i].t; | |
all+=td[i].d-now; | |
} | |
cout<<all; | |
return 0; | |
} |