Submission #1072491

#TimeUsernameProblemLanguageResultExecution timeMemory
1072491ArthuroWich전선 연결 (IOI17_wiring)C++17
13 / 100
29 ms3932 KiB
#include "wiring.h"
#include<bits/stdc++.h>
using namespace std;
long long min_total_length(vector<int> r, vector<int> b) {
	long long ans = 0, rbe, bbe;
	sort(r.rbegin(), r.rend());
	sort(b.begin(), b.end());
	rbe = r.front();
	bbe = b.front();
	for (int i = 0; i < min((int) r.size(), (int) b.size()); i++) {
		ans += abs(b[i]-r[i]);
	}
	if (r.size() < b.size()) {
		for (int i = r.size(); i < b.size(); i++) {
			ans += abs(rbe-b[i]);
		}
	} else {
		for (int i = b.size(); i < r.size(); i++) {
			ans += abs(bbe-r[i]);
		}
	}
	return ans;
}

Compilation message (stderr)

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:14:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |   for (int i = r.size(); i < b.size(); i++) {
      |                          ~~^~~~~~~~~~
wiring.cpp:18:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |   for (int i = b.size(); i < r.size(); i++) {
      |                          ~~^~~~~~~~~~
#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...