Submission #166064

#TimeUsernameProblemLanguageResultExecution timeMemory
166064itiamPreokret (COCI18_preokret)C++11
50 / 50
3 ms380 KiB
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;
int La[2883],Lb[2883];

int main(){
    int Na,Nb,x,m=0,mm,pp=0,brop=0;    //pp=prije poluvremena, brop=brojac  preokreta, m=max, mm=minimal..
    cin >> Na;
    for (int i=0;i<Na;i++){
        cin >> x;
        if (x>m)    m=x;
        if (x<mm || i==0)    mm=x;
        if (x<=1440)    pp+=1;
        La[x]=1;
    }
    cin >> Nb;
    for (int i=0;i<Nb;i++){
        cin >> x;
        if (x>m)    m=x;
        if (x<mm)    mm=x;
        if (x<=1440)    pp+=1;
        Lb[x]=1;
    }
    int p=0,pv;
    if (La[mm]==1)  pv=-1;
    else if (Lb[mm]==1)  pv=1;
    for (int i=mm;i<=m;i++){
        if (La[i]==1){
            p+=1;
        }
        else if (Lb[i]==1){
            p-=1;
        }
        if (p*pv>0){
            brop+=1;
            pv*=-1;
        }
    }
    cout << pp << "\n";
    cout << brop;
    return 0;
}

Compilation message (stderr)

preokret.cpp: In function 'int main()':
preokret.cpp:38:15: warning: 'pv' may be used uninitialized in this function [-Wmaybe-uninitialized]
             pv*=-1;
             ~~^~~~
preokret.cpp:9:21: warning: 'mm' may be used uninitialized in this function [-Wmaybe-uninitialized]
     int Na,Nb,x,m=0,mm,pp=0,brop=0;    //pp=prije poluvremena, brop=brojac  preokreta, m=max, mm=minimal..
                     ^~
#Verdict Execution timeMemoryGrader output
Fetching results...