65282023-12-07 09:34:52tamasmarkBányász RPG (40 pont)cpp17Hibás válasz 36/4070ms5140 KiB
// banayas rpg.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <deque>
#include <algorithm>

using namespace std;
struct adat
{
    int exp, db;
};
bool hasonlit(adat a, adat b)
{
    if (a.exp < b.exp) return 1;
    else return 0;
}
deque<adat>x;
int n, i, j, ido,maxi,dbexp=0,h,mini=9999999,k;
int main()
{
    cin >> n;
    x.resize(n + 1);
    for (i = 1; i <= n; ++i)
    {
        cin >> x[i].exp;
        if (x[i].exp < mini)
        {
            mini = x[i].exp;
            k = i;
        }
    }
    for (i = 1; i <= n; ++i)
    {
        cin >> x[i].db;
        if (x[i].db > maxi)
        {
            maxi = x[i].db;
            h = i;
        }
    }
    
    while (dbexp < mini)
    {
        ido += 2;
        dbexp++;
        x[h].db--;
    }
    sort(x.begin(), x.end(), hasonlit);
    for (i = 1; i <= n; ++i)
    {
        if (dbexp >= x[i].exp)
        {
            ido += x[i].db;
            dbexp += x[i].db;
        }
    }
    cout << ido;
    return 0;
}
/*
3
4 3 5
5 1 1
*/
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
RészfeladatÖsszpontTesztVerdiktIdőMemória
base36/40
1Elfogadva0/03ms1872 KiB
2Elfogadva0/014ms2324 KiB
3Elfogadva2/23ms2328 KiB
4Elfogadva2/23ms2308 KiB
5Elfogadva2/212ms2660 KiB
6Elfogadva2/220ms3148 KiB
7Elfogadva2/24ms2752 KiB
8Elfogadva2/26ms3104 KiB
9Elfogadva3/33ms2940 KiB
10Elfogadva3/33ms3308 KiB
11Elfogadva3/33ms3348 KiB
12Elfogadva3/33ms3600 KiB
13Elfogadva4/43ms3656 KiB
14Elfogadva4/43ms3644 KiB
15Hibás válasz0/241ms4560 KiB
16Elfogadva2/254ms4972 KiB
17Hibás válasz0/243ms4608 KiB
18Elfogadva2/270ms5140 KiB