236662026-01-27 08:40:24tamasnagyBányász RPG (40 pont)cpp17Időlimit túllépés 28/40400ms1076 KiB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct gyuri{
    int xp;
    int db;
};
vector<gyuri>matyi;
bool cmp(gyuri a, gyuri b){
    return a.xp<b.xp;
}

int main()
{
    int n,time=0,xp=0;
    cin>>n;
    matyi.resize(n);
    for(int i=0; i<n; i++){
        cin>>matyi[i].xp;
    }
    for(int i=0; i<n; i++){
        cin>>matyi[i].db;
    }
    sort(matyi.begin(), matyi.end(), cmp);
    int mini=0, maxi=n-1;
    while(mini<=maxi){
        while(xp<matyi[mini].xp && maxi>=mini){
            if(matyi[maxi].db>0){
                matyi[maxi].db--;
                time+=2;
                xp++;
            }
            else{
                maxi--;
            }
        }
        while(xp>=matyi[mini].xp && mini<=maxi){
            if(matyi[mini].db>0){
                matyi[mini].db--;
                time++;
                xp++;
            }
            else{
                mini++;
            }
        }

    }
    cout<<time;
    return 0;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base28/40
1Elfogadva0/01ms512 KiB
2Időlimit túllépés0/0377ms316 KiB
3Elfogadva2/21ms316 KiB
4Elfogadva2/22ms316 KiB
5Időlimit túllépés0/2400ms316 KiB
6Időlimit túllépés0/2398ms564 KiB
7Elfogadva2/26ms316 KiB
8Elfogadva2/2155ms428 KiB
9Elfogadva3/31ms344 KiB
10Elfogadva3/31ms316 KiB
11Elfogadva3/31ms316 KiB
12Elfogadva3/34ms508 KiB
13Elfogadva4/425ms404 KiB
14Elfogadva4/414ms316 KiB
15Időlimit túllépés0/2386ms564 KiB
16Időlimit túllépés0/2388ms820 KiB
17Időlimit túllépés0/2388ms1012 KiB
18Időlimit túllépés0/2388ms1076 KiB