173142025-06-23 13:05:26akososkaBányász RPG (40 pont)cpp17Wrong answer 0/401ms560 KiB
#include <bits/stdc++.h>

using namespace std;
int a[100001],n,b[100001],elso,utolso;
long long s,xp;
ifstream f("be.in");

int main()
{
    f>>n;
    for(int i=1;i<=n;i++){
        f>>a[i];
    }
    for(int i=1;i<=n;i++){
        f>>b[a[i]];
    }
    elso=1;
    utolso=6;
    while(elso<=utolso){
        if(b[elso]==0)elso++;
        else if(elso<=xp){
            s=s+b[elso];
            xp=xp+b[elso];
            elso++;
        }
        else if(b[utolso]==0)utolso--;
        else if(b[utolso]<=elso-xp){
            s=s+2*b[utolso];
            xp=xp+b[utolso];
            utolso--;
        }
        else{
            int q=elso-xp;
            b[utolso]=b[utolso]-q;
            s=s+2*q;
            xp=xp+q;
        }
    }
    cout<<s;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/40
1Wrong answer0/01ms316 KiB
2Wrong answer0/01ms316 KiB
3Wrong answer0/21ms316 KiB
4Wrong answer0/21ms316 KiB
5Wrong answer0/21ms560 KiB
6Wrong answer0/21ms508 KiB
7Wrong answer0/21ms372 KiB
8Wrong answer0/21ms328 KiB
9Wrong answer0/31ms560 KiB
10Wrong answer0/31ms508 KiB
11Wrong answer0/31ms316 KiB
12Wrong answer0/31ms316 KiB
13Wrong answer0/41ms316 KiB
14Wrong answer0/41ms344 KiB
15Wrong answer0/21ms500 KiB
16Wrong answer0/21ms316 KiB
17Wrong answer0/21ms316 KiB
18Wrong answer0/21ms316 KiB