d057. Q-4-16. 賺錢與罰款 - TCFSH CIRC Judge

本文最後更新於:2024年1月12日 下午

d057. Q-4-16. 賺錢與罰款 - TCFSH CIRC Judge

AP325-d057.cpp

// Author : ysh
// 07/24/2022 Sun 15:30:58.67
#include<bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;cin>>n;
    vector<pair<int,int>>f(n);
    for(auto &i : f) {
        cin>>i.first;
    }
    for(auto &i : f) {
        cin>>i.second;
    }
    sort(f.begin(),f.end(),[] (pair<int,int>a,pair<int,int>b) {
        // if(a.second != b.second) 
        return a.first < b.first;
        // return a.first < b.first;
    });
    int now = 0;
    long long ans = 0;
    for(pair<int,int> i : f) {
        now = now + i.first;
        ans = ans + (i.second - now);
    }
    cout<<ans;
    return 0;
}

d057. Q-4-16. 賺錢與罰款 - TCFSH CIRC Judge
http://mysh212.github.io/algosolution/AP325-d057.cpp/
作者
ysh
發布於
2022年7月24日
更新於
2024年1月12日
許可協議