Submission #100754

# Submission time Handle Problem Language Result Execution time Memory
100754 2019-03-14T07:43:56 Z shihan04 Wiring (IOI17_wiring) C++11
Compilation error
0 ms 0 KB
#include<iostream>
using namespace std;
int main()
{
    int n,m,r[100000],b[100000],greater;
    long long min=0;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>r[i];
    }
    for(int j=0;j<m;j++){
        cin>>b[j];
    }
    if(n<m){
        greater=m;
        for(int k=n;k<greater;k++){
            r[k]=r[n-1];
        }
    }
    else if(m<n){
        greater=n;
        for(int l=m;l<greater;l++){
            b[l]=b[m-1];
        }
    }
    for(int o=0;o<greater;o++){
        if(r[o]>b[o])
            min+=(r[o]-b[o]);
        else if(b[o]>r[o])
            min+=(b[o]-r[o]);
    }
    cout<<min;
    return 0;
}

Compilation message

wiring.cpp: In function 'int main()':
wiring.cpp:5:33: warning: 'greater' may be used uninitialized in this function [-Wmaybe-uninitialized]
     int n,m,r[100000],b[100000],greater;
                                 ^~~~~~~
/tmp/ccMlz4lT.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccmzTdca.o:wiring.cpp:(.text.startup+0x0): first defined here
/tmp/ccMlz4lT.o: In function `main':
grader.cpp:(.text.startup+0x23b): undefined reference to `min_total_length(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status