Submission #73234

# Submission time Handle Problem Language Result Execution time Memory
73234 2018-08-28T05:38:21 Z nvmdava Wiring (IOI17_wiring) C++17
0 / 100
3 ms 620 KB
#include "wiring.h"
#include <bits/stdc++.h>
using namespace std;

int a[200001];

long long min_total_length(std::vector<int> r, std::vector<int> b) {
	
	if(r.back() < b.back()){
		swap(r, b);
	}
	
	a[0] = 0;
	a[b.size()] = r.size();
	long long ans = 0;
	for(int i = 1; i < b.size(); i++){
		a[i] = upper_bound(r.begin(), r.end(), (b[i] + b[i - 1]) / 2) - r.begin();
	}
	for(int i = 0; i < b.size(); i++){
		for(int j = a[i]; j < a[i + 1]; j++){
			ans += (long long) abs(r[j] - b[i]);
		}
	}
	return ans;
}

Compilation message

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:16:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 1; i < b.size(); i++){
                 ~~^~~~~~~~~~
wiring.cpp:19:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < b.size(); i++){
                 ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 380 KB 3rd lines differ - on the 1st token, expected: '25859', found: '25290'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 480 KB 3rd lines differ - on the 1st token, expected: '904', found: '326'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 552 KB 3rd lines differ - on the 1st token, expected: '316', found: '188'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 620 KB 3rd lines differ - on the 1st token, expected: '27', found: '16'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 380 KB 3rd lines differ - on the 1st token, expected: '25859', found: '25290'
2 Halted 0 ms 0 KB -