# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1022961 | 2024-07-14T08:02:33 Z | hirayuu_oj | Wiring (IOI17_wiring) | C++17 | 24 ms | 3932 KB |
#include "wiring.h" #include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0; i<(n); i++) using ll=long long; long long min_total_length(std::vector<int> r, std::vector<int> b) { if(r.size()<=1000&&b.size()<=1000){ if(r.size()<b.size())swap(r,b); int n=r.size(); int m=b.size(); vector<ll> dp(m,1LL<<60); dp[0]=abs(r[0]-b[0]); for(int k=1; k<m; k++)dp[k]=dp[k-1]+abs(r[0]-b[k]); for(int i=1; i<n; i++){ vector<ll> ndp(m,1LL<<60); rep(j,m){ ndp[j]=min(ndp[j],dp[j]+abs(r[i]-b[j])); ll cbl=0; for(int k=j+1; k<m; k++){ cbl+=abs(r[i]-b[k]); ndp[k]=min(ndp[k],dp[j]+cbl); } } swap(dp,ndp); } return dp[m-1]; } else{ ll ans=0; rep(i,max(b.size(),r.size())){ ans+=abs(r[min((int)r.size()-1,i)]-b[max(0,(int)b.size()-1-i)]); } return ans; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 344 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 5 ms | 440 KB | Output is correct |
8 | Correct | 5 ms | 348 KB | Output is correct |
9 | Correct | 5 ms | 348 KB | Output is correct |
10 | Correct | 5 ms | 444 KB | Output is correct |
11 | Correct | 5 ms | 348 KB | Output is correct |
12 | Correct | 5 ms | 444 KB | Output is correct |
13 | Correct | 5 ms | 348 KB | Output is correct |
14 | Correct | 5 ms | 444 KB | Output is correct |
15 | Correct | 5 ms | 344 KB | Output is correct |
16 | Correct | 5 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 14 ms | 2908 KB | Output is correct |
4 | Correct | 14 ms | 2908 KB | Output is correct |
5 | Correct | 15 ms | 2936 KB | Output is correct |
6 | Correct | 17 ms | 3664 KB | Output is correct |
7 | Correct | 17 ms | 3776 KB | Output is correct |
8 | Correct | 17 ms | 3932 KB | Output is correct |
9 | Correct | 18 ms | 3904 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 600 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Incorrect | 24 ms | 3772 KB | 3rd lines differ - on the 1st token, expected: '1068938599', found: '50007297754611' |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Incorrect | 14 ms | 3164 KB | 3rd lines differ - on the 1st token, expected: '373710605', found: '10000000000' |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 344 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 5 ms | 440 KB | Output is correct |
8 | Correct | 5 ms | 348 KB | Output is correct |
9 | Correct | 5 ms | 348 KB | Output is correct |
10 | Correct | 5 ms | 444 KB | Output is correct |
11 | Correct | 5 ms | 348 KB | Output is correct |
12 | Correct | 5 ms | 444 KB | Output is correct |
13 | Correct | 5 ms | 348 KB | Output is correct |
14 | Correct | 5 ms | 444 KB | Output is correct |
15 | Correct | 5 ms | 344 KB | Output is correct |
16 | Correct | 5 ms | 348 KB | Output is correct |
17 | Correct | 1 ms | 348 KB | Output is correct |
18 | Correct | 1 ms | 348 KB | Output is correct |
19 | Correct | 14 ms | 2908 KB | Output is correct |
20 | Correct | 14 ms | 2908 KB | Output is correct |
21 | Correct | 15 ms | 2936 KB | Output is correct |
22 | Correct | 17 ms | 3664 KB | Output is correct |
23 | Correct | 17 ms | 3776 KB | Output is correct |
24 | Correct | 17 ms | 3932 KB | Output is correct |
25 | Correct | 18 ms | 3904 KB | Output is correct |
26 | Correct | 1 ms | 600 KB | Output is correct |
27 | Correct | 0 ms | 344 KB | Output is correct |
28 | Incorrect | 24 ms | 3772 KB | 3rd lines differ - on the 1st token, expected: '1068938599', found: '50007297754611' |
29 | Halted | 0 ms | 0 KB | - |