Submission #298222

# Submission time Handle Problem Language Result Execution time Memory
298222 2020-09-12T15:31:05 Z dantoh000 Wiring (IOI17_wiring) C++14
0 / 100
1 ms 384 KB
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const ll INF = 1000000000000000000;
//#include "wiring.h"
ll dp[200005];
ll p[200005];
int last[200005];
vector<ii> v;
ll min_total_length(vector<int> r, vector<int> b) {
    int nr = r.size(), nb = b.size();
    int n = nr+nb;
    for (auto x: r) v.push_back({x,0});
    for (auto x: b) v.push_back({x,1});
    sort(v.begin(),v.end());
    last[0] = -1;
    dp[0] = 0;
    p[0] = v[0].fi;
    for (int i = 1; i < n; i++){
        dp[i] = INF;
        last[i] = (v[i].se == v[i-1].se) ? last[i-1] : i-1;
        p[i] = p[i-1] + v[i].fi;
        if (last[i] == -1) continue;
        dp[i] = dp[i-1] + v[i].fi - v[last[i]].fi;
        int pos = last[i]-(i-last[i]);
        if (last[last[i]] <= pos){
            dp[i] = min(dp[i],dp[pos]+p[i]-p[last[i]]-(p[last[i]]-p[pos]));
        }
        //printf("%d ",dp[i]);
    }
	return dp[n-1];
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB 3rd lines differ - on the 1st token, expected: '25859', found: '23822'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB 3rd lines differ - on the 1st token, expected: '904', found: '1000000000000000326'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB 3rd lines differ - on the 1st token, expected: '316', found: '272'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB 3rd lines differ - on the 1st token, expected: '27', found: '23'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB 3rd lines differ - on the 1st token, expected: '25859', found: '23822'
2 Halted 0 ms 0 KB -