Submission #794158

#TimeUsernameProblemLanguageResultExecution timeMemory
794158TheSahibWiring (IOI17_wiring)C++14
13 / 100
23 ms3884 KiB
#include "wiring.h"
#include <bits/stdc++.h>

using namespace std;

long long min_total_length(vector<int> r, vector<int> b) {
    if(r.size() < b.size()){
        swap(r, b);
        reverse(b.begin(), b.end());
    }
    int p1 = 0, p2 = 0;
    long long ans = 0;
    while(p1 != r.size() && p2 != b.size()){
        ans += abs(r[p1] - b[p2]);
        p1++;
        p2++;
    }
    while(p1 != r.size()){
        ans += min(abs(r[p1] - b[0]), abs(r[p1] - b.back()));
        p1++;
    }
    return ans;
}

Compilation message (stderr)

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:13:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     while(p1 != r.size() && p2 != b.size()){
      |           ~~~^~~~~~~~~~~
wiring.cpp:13:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     while(p1 != r.size() && p2 != b.size()){
      |                             ~~~^~~~~~~~~~~
wiring.cpp:18:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     while(p1 != r.size()){
      |           ~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...