239952026-02-03 08:59:55BitProBányász RPG (40 pont)cpp17Compilation error
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int n, time=0, xp=0;

struct erc
{
    int kuszob, db;
};

bool cmp (erc a, erc b)
{
    return a.kuszob < b.kuszob;
}
vector<erc> lista;
int main()
{
    cin>>n;
    lista.resize(n);

    for(int i=0; i<n; i++)        ///beolvas
    {
        cin>>lista[i].kuszob;
    }
    for(int i=0; i<n; i++)
    {
        cin>>lista[i].db;
    }                           ///idaig

    int i=0, j=n-1;
    sort(lista.begin(), lista.end(), cmp);
    while (i != j)
    {
        if(xp >= lista[i].kuszob)
        {
            xp+=lista[i].db;
            time+=lista[i].db;
            i++;
        }
        else
        {
            if(lista[i].kuszob - xp < lista[j].db)
            {
                int need = lista[i].kuszob - xp;
                lista[j].db -= need;
                xp += need;
                time += 2 * need;
            }
            else if (lista[i].kuszob - xp == lista[j].db)
            {
                xp+=lista[j].db;
                time+=2*lista[j].db;
                j--;
            }
            else
            {
                xp+=lista[j].db;
                time+=2*lista[j].db;
                j--;
            }
        }
    }
    while(lista[i].db >0)
    {
        if(xp<lista[i].kuszob)
        {
            xp++;
            time+=2;
        }
        else
        {
            xp++;
            time++;
        }
        lista[i].db--;
    }
    cout << time;
    return 0;
}
Compilation error
open /var/local/lib/isolate/443/box/a.out: no such file or directory
main.cpp:6:8: error: 'int time' redeclared as different kind of entity
    6 | int n, time=0, xp=0;
      |        ^~~~
In file included from /usr/include/pthread.h:23,
                 from /usr/include/x86_64-linux-gnu/c++/12/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/12/bits/gthr.h:148,
                 from /usr/include/c++/12/ext/atomicity.h:35,
                 from /usr/include/c++/12/bits/ios_base.h:39,
                 from /usr/include/c++/12/ios:42,
                 from /usr/include/c++/12/ostream:38,
                 from /usr/include/c++/12/iostream:39,
                 from main.cpp:1:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
   76 | extern time_t time (time_t *__timer) __THROW;
      |               ^~~~
main.cpp: In function 'int main()':
main.cpp:39:17: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   39 |             time+=lista[i].db;
      |             ~~~~^~~~~~~~~~~~~
main.cpp:39:17: error: assignment of read-only location 'time'
main.cpp:49:22: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   49 |                 time += 2 * need;
      |                 ~~~~~^~~~~~~~~~~
main.cpp:49:22: error: assignment of read-only location 'time'
main.cpp:54:21: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   54 |                 time+=2*lista[j].db;
      |                 ~~~~^~~~~~~~~~~~~~~
main.cpp:54:21: error: assignment of read-only location 'time'
main.cpp:60:21: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   60 |                 time+=2*lista[j].db;
      |                 ~~~~^~~~~~~~~~~~~~~
main.cpp:60:21: error: assignment of read-only location 'time'
main.cpp:70:17: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   70 |             time+=2;
      |             ~~~~^~~
main.cpp:70:17: error: assignment of read-only location 'time'
main.cpp:...