Submission #1043049

#TimeUsernameProblemLanguageResultExecution timeMemory
1043049YassirSalamaWiring (IOI17_wiring)C++17
13 / 100
15 ms3932 KiB
#include "wiring.h" #include<bits/stdc++.h> using namespace std; const int maxn=300; long long dp[maxn][maxn]; long long cost(long long a,long long b){ return max(a,b)-min(a,b); } long long min_total_length(vector<int> r, vector<int> b) { long long ans=0; int n=r.size(); int m=b.size(); int i=0; int j=0; if(m>=n){ while(i<n&&j<m){ ans+=b[j]-r[i]; if(i==n-1&&j==m-1) break; if(i+1<n) i++; if(j+1<m) j++; } }else{ int a=n; int c=m; while(a>c){ ans+=b[j]-r[i]; i++; a--; } while(i<n&&j<m){ ans+=b[j]-r[i]; if(i==n-1&&j==m-1) break; if(i+1<n) i++; if(j+1<m) j++; } } return ans; } #ifdef IOI #include "wiring.h" #include <cassert> #include <cstdio> using namespace std; int main() { int n, m; assert(2 == scanf("%d %d", &n, &m)); vector<int> r(n), b(m); for(int i = 0; i < n; i++) assert(1 == scanf("%d", &r[i])); for(int i = 0; i < m; i++) assert(1 == scanf("%d", &b[i])); long long res = min_total_length(r, b); printf("%lld\n", res); return 0; } #endif
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...