Submission #99092

# Submission time Handle Problem Language Result Execution time Memory
99092 2019-02-28T14:17:11 Z figter001 Wiring (IOI17_wiring) C++14
0 / 100
3 ms 256 KB
#include "wiring.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int nax = 2e5 + 50;

ll dp[nax];

long long min_total_length(vector<int> r, vector<int> b) {
	vector<pair<ll,int>> a;
	for(int i : r)
		a.push_back({i,0});
	for(int i : b)
		a.push_back({i,1});
	sort(a.begin(),a.end());
	int n = a.size();
	for(int i=0;i<=n;i++)
		dp[i] = 1e18;
	dp[0] = 0;
	int lr = -1,lb = -1;
	int id1 = -1,id2 = -1;
	for(int i=1;i<=n;i++){
		pair<int,int> cur = a[i-1];
		ll at = cur.first;
		if(cur.first == 0){
			if(lb != -1)
				dp[i] = min(dp[i],dp[id2-1] + at - lb);
			lr = at;
			id1 = i;
		}else{
			if(lr != -1)
				dp[i] = min(dp[i],dp[id1-1] + at - lr);
			lb = at;
			id2 = i;
		}
	}
	return dp[n];
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB 3rd lines differ - on the 1st token, expected: '25859', found: '1000000000000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB 3rd lines differ - on the 1st token, expected: '904', found: '1000000000000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 256 KB 3rd lines differ - on the 1st token, expected: '316', found: '101'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB 3rd lines differ - on the 1st token, expected: '27', found: '1000000000000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB 3rd lines differ - on the 1st token, expected: '25859', found: '1000000000000000000'
2 Halted 0 ms 0 KB -