# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
914570 | 2024-01-22T10:49:24 Z | tosivanmak | 전선 연결 (IOI17_wiring) | C++17 | 1 ms | 600 KB |
#include<bits/stdc++.h> using namespace std; #define ll long long long long min_total_length(vector<int> r, vector<int> b) { r.insert(r.begin(), 0); b.insert(b.begin(),0); if(r.size()<b.size()){ swap(r,b); } ll dp[r.size()+5][b.size()+5]; ll n=r.size(),m=b.size(); for(int i=0;i<r.size()+5;i++){ for(int j=0;j<b.size()+5;j++){ dp[i][j]=1e17; } } dp[0][0]=0; dp[1][0]=0; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ dp[i][j]=min({dp[i][j-1], dp[i-1][j]})+abs(r[i]-b[j]); } } return dp[n][m]; } #ifdef LOCAL int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n,m; cin>>n>>m; vector<int>v,v2; for(int i=1;i<=n;i++){ ll x; cin>>x; v.push_back(x); } for(int i=1;i<=m;i++){ ll x; cin>>x; v2.push_back(x); } cout<<min_total_length(v,v2)<<'\n'; } #endif
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 436 KB | 3rd lines differ - on the 1st token, expected: '25859', found: '46184' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 600 KB | 3rd lines differ - on the 1st token, expected: '904', found: '999' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | 3rd lines differ - on the 1st token, expected: '316', found: '400' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 436 KB | 3rd lines differ - on the 1st token, expected: '27', found: '59' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 436 KB | 3rd lines differ - on the 1st token, expected: '25859', found: '46184' |
2 | Halted | 0 ms | 0 KB | - |