166662025-05-08 11:30:05ercseferencBányász RPG (40 pont)cpp17Wrong answer 33/40400ms3512 KiB
#include <bits/stdc++.h>
using namespace std;
struct erc{int ido,ar,ind;};
bool has1(erc n, erc m){
    return n.ido<m.ido;}
bool has2(erc n, erc m){
    return n.ar>m.ar;}
int main()
{
    long long n,coun=0; cin>>n;
    vector<erc>a(n),b(n),c(n);
    for(int i=0; i<n; i++){cin>>a[i].ido; a[i].ind=i;}
    for(int i=0; i<n; i++){cin>>a[i].ar; coun+=a[i].ar;}
    b=a; c=a;
    sort(a.begin(),a.end(),has1);
    sort(b.begin(),b.end(),has2);
    long long xp=0,ido=0; int aszam=0,bszam=0;
    while(aszam<n-1){
        while(c[a[aszam].ind].ar==0){aszam++;}
        int t=xp;
        for(int i=t; i<a[aszam].ido; i++){
            if(c[b[bszam].ind].ar==0)bszam++;
            xp++; ido+=2; c[b[bszam].ind].ar--;}
        while(c[a[aszam].ind].ar>0){
            xp++; ido++; c[a[aszam].ind].ar--;}}
    cout<<ido;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base33/40
1Accepted0/01ms316 KiB
2Accepted0/014ms1016 KiB
3Accepted2/21ms316 KiB
4Accepted2/22ms316 KiB
5Accepted2/210ms864 KiB
6Accepted2/224ms1500 KiB
7Accepted2/23ms316 KiB
8Accepted2/24ms564 KiB
9Wrong answer0/31ms316 KiB
10Accepted3/31ms316 KiB
11Accepted3/31ms316 KiB
12Accepted3/31ms316 KiB
13Accepted4/41ms420 KiB
14Accepted4/41ms316 KiB
15Time limit exceeded0/2400ms2100 KiB
16Accepted2/261ms2780 KiB
17Time limit exceeded0/2400ms2104 KiB
18Accepted2/279ms3512 KiB