Submission #73223

# Submission time Handle Problem Language Result Execution time Memory
73223 2018-08-28T05:23:33 Z nvmdava Wiring (IOI17_wiring) C++17
0 / 100
3 ms 536 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();
		if(a[i] <= a[i - 1]) a[i] = a[i - 1] + 1;
	}
	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:20: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 248 KB 3rd lines differ - on the 1st token, expected: '25859', found: '29117'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 484 KB 3rd lines differ - on the 1st token, expected: '904', found: '1016'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 536 KB Output is correct
2 Incorrect 3 ms 536 KB 3rd lines differ - on the 1st token, expected: '17703', found: '19052'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 536 KB 3rd lines differ - on the 1st token, expected: '27', found: '60'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 248 KB 3rd lines differ - on the 1st token, expected: '25859', found: '29117'
2 Halted 0 ms 0 KB -