# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
43181 |
2018-03-10T11:57:20 Z |
yusufake |
Wiring (IOI17_wiring) |
C++ |
|
44 ms |
10004 KB |
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define st first
#define nd second
typedef long long ll;
const ll inf = 1e18 + 1;
const int mod = 1e9 + 7;
const int N = 2e5 + 5;
pair < ll , int > T[N];
ll L[N],R[N],t,dp[N],p[N];
void bld(ll l, ll r, ll x, ll y){
ll i,sz,p=0;
for(sz=1,i=r; i>=l ;i--, sz++){
p += T[i].st;
L[sz] = min(dp[i],dp[i-1]) - p + sz*x;
R[sz] = min(dp[i],dp[i-1]) - p + sz*y;
}
}
ll min_total_length(vector < int > a, vector < int > b){
int n,m,i,j;
n = a.size(); m = b.size();
for(i=j=0; i<n || j<m ;){
if(j == m || (i < n && a[i]<b[j])) T[++t] = mp(a[i++],1);
else T[++t] = mp(b[j++],2);
}
ll l,r,x,y,sz,mn,k;
memset(L , 22 , sizeof L);
memset(R , 22 , sizeof R);
for(i=1;T[i].nd == T[i+1].nd ; i++) dp[i] = inf;
l = 1; r = i;
dp[i] = inf;
for(i++;i<=t;i = r+1){
for(j=i ;T[j].nd == T[j+1].nd ; j++);
x = T[i].st;
y = T[i-1].st;
bld(l,r,x,y);
mn = inf;
for(sz=1,k=i;k<=j;k++,sz++){
p[sz] = p[sz-1] + T[k].st;
mn = min(mn , R[sz]);
dp[k] = mn + p[sz] - sz*y;
}
mn = inf;
for(sz=j-i+1,k=j; k>=i ;k--,sz--){
mn = min(mn , L[sz]);
dp[k] = min(dp[k] , mn + p[sz] - sz*x);
}
for(k=1;k<=r-l+1;k++) L[k] = R[k] = inf;
l = i; r = j;
}
return dp[t];
}
//int main(){
// cout << min_total_length({1, 2, 3, 7}, {0, 4, 5, 9, 10});
//}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
6524 KB |
Output is correct |
2 |
Incorrect |
6 ms |
6624 KB |
3rd lines differ - on the 1st token, expected: '14340', found: '14522' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
6696 KB |
3rd lines differ - on the 1st token, expected: '904', found: '1000000000000000281' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
6696 KB |
Output is correct |
2 |
Correct |
5 ms |
6744 KB |
Output is correct |
3 |
Incorrect |
44 ms |
9836 KB |
3rd lines differ - on the 1st token, expected: '1068938599', found: '1000000000000016523' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
9836 KB |
Output is correct |
2 |
Incorrect |
35 ms |
10004 KB |
3rd lines differ - on the 1st token, expected: '373710605', found: '409801698' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
6524 KB |
Output is correct |
2 |
Incorrect |
6 ms |
6624 KB |
3rd lines differ - on the 1st token, expected: '14340', found: '14522' |
3 |
Halted |
0 ms |
0 KB |
- |