Submission #81187

# Submission time Handle Problem Language Result Execution time Memory
81187 2018-10-24T04:00:08 Z GoodTrung Wiring (IOI17_wiring) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define NAME "wiring"
using namespace std;
typedef long long LL;
typedef pair <int, int> pii;
typedef double DB;
typedef pair <LL, LL> pLL;
const int NMAX = 1e6+7;

int n, m;

LL min_total_length(vector <int> r, vector <int> b) {
    LL res = 0;
    n = r.size();
    m = b.size();
    if(r[n-1] < b[0]) {
        for(int i = 0; i < n; ++i)
            res -= r[i];
        for(int i = 0; i < m; ++i)
            res += b[i];
        res += LL(max(n - m, 0)) * b[0];
        res -= LL(max(m - n, 0)) * r[n-1];
        return res;
    }
    return -1;
}

vector <int> ver, veb;
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen(NAME".inp", "r", stdin);
    //freopen(NAME".out", "w", stdout);
    cin >> n >> m;
    int x;
    for(int i = 0; i < n; ++i) {
        cin >> x;
        ver.push_back(x);
    }
    for(int i = 0; i < m; ++i) {
        cin >> x;
        veb.push_back(x);
    }
    cout << min_total_length(ver, veb);
}

Compilation message

wiring.cpp: In function 'int main()':
wiring.cpp:33:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen(NAME".inp", "r", stdin);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/tmp/ccptm6Ht.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccGCmUSC.o:wiring.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status