89252024-02-05 16:54:00KristófVásárlás (75 pont)cpp17Wrong answer 0/7561ms6728 KiB
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[n];
    int b[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    int meg=0;
    int inter=b[0]-a[0];
    int bat=b[0];
    int aat=b[0]-a[0];
    int mbat=0;
    int max=-1;
    int maxat=0;
    for(int i=1;i<n;i++){
        if(inter>=0){

            inter+=b[i]-a[i];
            bat+=b[i];
            aat+=a[i];
           
        }
        if(inter<0 || i==n-1){
                
            if(inter<0){
            aat-=a[i];
            inter+=a[i]-b[i];
            }
            if(inter>max){
            max=inter;
            maxat=aat;
            
            inter=0;
            meg+=mbat;
            mbat=bat;
            bat=0;
            aat=0;
            }
            else{
                inter=0;
                aat=0;
                meg+=bat;
                bat=0;
            }
        }



    }
    meg+=maxat;
    cout<<meg;














    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/75
1Accepted0/03ms1876 KiB
2Wrong answer0/030ms3404 KiB
3Wrong answer0/33ms2812 KiB
4Wrong answer0/43ms3028 KiB
5Wrong answer0/43ms3368 KiB
6Wrong answer0/43ms3308 KiB
7Wrong answer0/43ms3316 KiB
8Wrong answer0/33ms3428 KiB
9Wrong answer0/44ms3676 KiB
10Wrong answer0/44ms3772 KiB
11Wrong answer0/44ms3688 KiB
12Wrong answer0/54ms3964 KiB
13Wrong answer0/357ms6372 KiB
14Wrong answer0/357ms6516 KiB
15Wrong answer0/357ms6368 KiB
16Wrong answer0/357ms6496 KiB
17Wrong answer0/357ms6580 KiB
18Wrong answer0/357ms6684 KiB
19Wrong answer0/356ms6728 KiB
20Wrong answer0/359ms6720 KiB
21Wrong answer0/359ms6580 KiB
22Wrong answer0/341ms6676 KiB
23Wrong answer0/361ms6684 KiB
24Wrong answer0/357ms6676 KiB