236602026-01-27 08:34:49tamasnagyBányász RPG (40 pont)cpp17Wrong answer 0/40400ms1844 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);
    for(int i=0; i<n; i++){
        cout<<matyi[i].xp<<' '<<matyi[i].db<<endl;
    }
    int mini=0, maxi=n-1;
    while(mini<=maxi){
        while(xp<matyi[mini].xp){
            if(matyi[maxi].db>0){
                matyi[maxi].db--;
                time+=2;
                xp++;
            }
            else{
                maxi--;
            }
        }
        while(xp>=matyi[mini].xp){
            if(matyi[mini].db>0){
                matyi[mini].db--;
                time++;
                xp++;
            }
            else{
                mini++;
            }
        }

    }
    cout<<time;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/40
1Wrong answer0/01ms508 KiB
2Time limit exceeded0/0379ms560 KiB
3Wrong answer0/21ms316 KiB
4Wrong answer0/24ms316 KiB
5Time limit exceeded0/2400ms492 KiB
6Time limit exceeded0/2398ms984 KiB
7Wrong answer0/213ms316 KiB
8Wrong answer0/2202ms316 KiB
9Wrong answer0/31ms316 KiB
10Wrong answer0/31ms316 KiB
11Wrong answer0/31ms316 KiB
12Wrong answer0/37ms316 KiB
13Wrong answer0/432ms316 KiB
14Wrong answer0/418ms316 KiB
15Time limit exceeded0/2381ms1332 KiB
16Time limit exceeded0/2400ms1592 KiB
17Time limit exceeded0/2400ms1336 KiB
18Time limit exceeded0/2400ms1844 KiB