94482024-02-21 20:41:35Vkrisztian01Bányász RPG (40 pont)cpp11Wrong answer 36/4068ms4532 KiB
#include <iostream>
#include<vector>
#include<set>
#include<algorithm>

using namespace std;

 int n,k;
 int ido=0,pont=0;
vector<pair<int,int> > lista;

int main()
{
    cin>>n;
    lista.resize(n);
    for(int i=0;i<n;i++) cin>>lista[i].first;
    for(int i=0;i<n;i++) cin>>lista[i].second;
    sort(lista.begin(),lista.end());
    int eleje=0,vege=n-1;
    while(eleje<=vege)
    {
        while(vege>=eleje && pont<lista[eleje].first)
        {
            k=max(0,min(lista[eleje].first-pont,lista[vege].second));
            //cout<<k;
            ido+=2*k;
            pont+=k;
            lista[vege].second-=k;
            if(lista[vege].second==0) --vege;
        }
        ido+=lista[eleje].second;
        pont+=lista[eleje].second;
        ++eleje;
    }
    cout<<ido;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base36/40
1Accepted0/03ms1876 KiB
2Accepted0/014ms2320 KiB
3Accepted2/23ms2552 KiB
4Accepted2/23ms2512 KiB
5Accepted2/212ms2952 KiB
6Accepted2/223ms3316 KiB
7Accepted2/24ms2884 KiB
8Accepted2/26ms2988 KiB
9Accepted3/32ms3080 KiB
10Accepted3/33ms3224 KiB
11Accepted3/33ms3248 KiB
12Accepted3/33ms3332 KiB
13Accepted4/43ms3356 KiB
14Accepted4/43ms3332 KiB
15Wrong answer0/239ms4008 KiB
16Accepted2/252ms4140 KiB
17Wrong answer0/243ms4012 KiB
18Accepted2/268ms4532 KiB