Submission #978886

# Submission time Handle Problem Language Result Execution time Memory
978886 2024-05-10T00:17:30 Z Lalic Wiring (IOI17_wiring) C++17
13 / 100
18 ms 4240 KB
#include "wiring.h"
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define mp make_pair

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e5+10;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;

ll min_total_length(vector<int> r, vector<int> b) {
	int n=(int)r.size(), m=(int)b.size();
	
	if(n>m){
		swap(n, m);
		swap(r, b);
	}
	
	r.pb(-1e9-2);
	ll ans=0;
	int last=0;
	for(int i=0;i<n;i++){
		int low=last+1, high=m-n+i, best=last;
		while(low<=high){
			int mid=(low+high)>>1;
			if(abs(b[mid]-r[i])<=abs(b[mid]-r[i+1])){
				best=mid;
				low=mid+1;
			}
			else high=mid-1;
		}
		
		while(last<=best){
			ans+=abs(b[last]-r[i]);
			last++;
		}
	}
	
	return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 3rd lines differ - on the 1st token, expected: '25859', found: '26187'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 12 ms 3068 KB Output is correct
4 Correct 13 ms 3164 KB Output is correct
5 Correct 14 ms 3196 KB Output is correct
6 Correct 17 ms 4188 KB Output is correct
7 Correct 18 ms 4240 KB Output is correct
8 Correct 17 ms 4188 KB Output is correct
9 Correct 17 ms 4180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 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 1 ms 344 KB 3rd lines differ - on the 1st token, expected: '27', found: '30'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 3rd lines differ - on the 1st token, expected: '25859', found: '26187'
2 Halted 0 ms 0 KB -