Submission #420102

# Submission time Handle Problem Language Result Execution time Memory
420102 2021-06-08T05:51:36 Z Maqsut_03 Wiring (IOI17_wiring) C++14
0 / 100
1 ms 308 KB
#include "wiring.h"
#include<bits/stdc++.h>
using namespace std;
#define N 200100
int n, m, a[N];
long long ans = 0;

long long min_total_length(vector<int> r, vector<int> b) 
{
	n = r.size();
	m = b.size();
	for (int i=0; i<n; i++) 
	{
		long long  mn = 1e18;
		int k = 0;
		for (int j=0; j<m; j++)
		{
			if (abs(r[i] - b[j]) <= mn) mn = abs(r[i] - b[j]), k = j;
		}
		a[k]++;
		ans += mn;
	}
	
	for (int i=0; i<m; i++)
	{
		if (a[i] == 0)
		{
			long long  mn = 1e18;
			for (int j=0; j<n; j++)
				mn = min(mn, 1ll*abs(b[i] - r[j]));
			for (int j=0; j<m; j++)
			    mn = min(mn, 1ll*abs(b[i] - b[j]));
			ans += mn;    
		}
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 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 1 ms 204 KB 3rd lines differ - on the 1st token, expected: '904', found: '623'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB 3rd lines differ - on the 1st token, expected: '316', found: '176'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 308 KB 3rd lines differ - on the 1st token, expected: '27', found: '18'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB 3rd lines differ - on the 1st token, expected: '25859', found: '25290'
2 Halted 0 ms 0 KB -