244822026-02-12 09:27:11BitProBányász RPG (40 pont)cpp17Forditási hiba
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

long long n, time=0, xp=0;

struct erc
{
    long long 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
    {
        long long need = lista[i].kuszob - xp;

        if (need <= 0)
        {
            i++;
            continue;
        }

        if (lista[j].db > need)
        {
            lista[j].db -= need;
            xp += need;
            time += 2 * need;
        }
        else
        {
            xp += lista[j].db;
            time += 2 * lista[j].db;
            j--;
        }
    }
}
    while(lista[i].db >0)
    {
        if(xp<lista[i].kuszob)
        {
            time+=2;
        }
        else
        {
            time++;
        }
        xp++;
        lista[i].db--;
    }
    cout << time;
    return 0;
}
Forditási hiba
open /var/local/lib/isolate/428/box/a.out: no such file or directory
main.cpp:6:14: error: 'long long int time' redeclared as different kind of entity
    6 | long long 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:14: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   39 |         time += lista[i].db;
      |         ~~~~~^~~~~~~~~~~~~~
main.cpp:39:14: error: assignment of read-only location 'time'
main.cpp:56:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   56 |             time += 2 * need;
      |             ~~~~~^~~~~~~~~~~
main.cpp:56:18: error: assignment of read-only location 'time'
main.cpp:61:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   61 |             time += 2 * lista[j].db;
      |             ~~~~~^~~~~~~~~~~~~~~~~~
main.cpp:61:18: 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:74:13: warning: ISO C++ forbids incrementing a pointer of type 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} [-Wpointer-arith]
   74 |             time++;
      |             ^~~~
main.cpp:74:13: err...