QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#32798#2281. BnPCRobeZH#WA 2ms3584kbC++1.2kb2022-05-24 03:43:452022-05-24 03:43:45

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-24 03:43:45]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3584kb
  • [2022-05-24 03:43:45]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=1;i<=n;++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define st first
#define nd second
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long ll;
int n,k,l;
map<string,int>a;
map<string,vi>e;
ll ans,infmx;
vector<ll>ftp;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>k;
    rep(i,n){
        string s;int x;
        cin>>s>>x;
        a[s]=x;
    }
    cin>>l;
    rep(i,l){
        string s;int x;
        cin>>s>>x;
        e[s].pb(x);
    }
    ans=infmx=0;
    for(auto p:a){
        vi&v=e[p.st];
        if(v.size()==0)continue;
        sort(all(v));
        int mx=v.back();
        if(mx>p.nd)k-=mx-p.nd;
        ll cnt=0;
        for(int x:v)if(x<mx)ans+=mx;else ++cnt;
        infmx=max(infmx,(ll)v.size());
        ftp.pb(cnt*mx+v.size());
    }
    sort(all(ftp));
    if(k<0)cout<<0<<endl;
    else{
        while(k>0&&ftp.size()>0&&ftp.back()>infmx){
            ans+=ftp.back();
            --k;
            ftp.pop_back();
        }
        ans+=k*infmx;
        cout<<ans<<endl;
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3512kb

input:

3 14
THISISTHEONE 8
B 0
C 0
8
THISISTHEONE 10
C 0
B 1
B 0
THISISTHEONE 0
C 1
THISISTHEONE 0
THISISTHEONE 0

output:

82

result:

ok single line: '82'

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 3584kb

input:

3 99
THEFIRSTINCREASE 6
SECONDINCREASE 4
ZZZ 1
9
THEFIRSTINCREASE 4
ZZZ 0
THEFIRSTINCREASE 6
SECONDINCREASE 8
THEFIRSTINCREASE 2
SECONDINCREASE 1
ZZZ 0
SECONDINCREASE 8
THEFIRSTINCREASE 3

output:

427

result:

wrong answer 1st lines differ - expected: '429', found: '427'