제출 #288357

#제출 시각아이디문제언어결과실행 시간메모리
288357kevlee전선 연결 (IOI17_wiring)C++17
13 / 100
39 ms3832 KiB
#include "wiring.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 1000000007
#define h1 7897897897897897
#define h2 7897466719774591
#define b1 98762051
#define b2 98765431
#define inf 1000000000
#define pi 3.1415926535897932384626
#define LMAX 9223372036854775807
#define ll long long
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pii>
#define SET(a, b) memset(a, b, sizeof(a));
#define all(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
long long min_total_length(vector<int> a, vector<int> b) {
  ll ans = 0;
  int n = a.size(), m = b.size();
  if (n > m) {
    FOR(i, 0, m-1) {
    ans += abs(a[i] - b[i]);
  }
    FOR(i, m, n-1) {
      ans += abs(a[i] - b[0]);
    }
  } else {
    FOR(i, 0, n-1) {
    ans += abs(a[i] - b[i]);
  }
    FOR(i, n, m-1) {
      ans += abs(b[i] - a[n-1]);
    }
  }
  
  return ans;
}
#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...