Submission #496836

#TimeUsernameProblemLanguageResultExecution timeMemory
496836vinnipuh01Coin Collecting (JOI19_ho_t4)C++17
0 / 100
1 ms332 KiB
#include <iostream> #include <bits/stdc++.h> #include <cmath> #include <algorithm> #include <vector> #include <deque> #include <set> #include <stack> #include <string> #include <map> #include <queue> using namespace std; const long long oo = 1000000000000000000; long long int sum, ans = 0, mx = 0, mn = 1000000000, num, pos; /* ViHHiPuh (( `'-""``""-'` )) )-__-_.._-__-( / --- (o _ o) --- \ \ .-* ( .0. ) *-. / _'-. ,_ '=' _, .-'_ / `;#'#'# - #'#'#;` \ \_)) -----'#'----- ((_/ # --------- # '# ------- ------ #' /..-'# ------- #'-.\ _\...-\'# -- #'/-.../_ ((____)- '#' -(____)) cout << fixed << setprecision(6) << x; ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); freopen ( "sum.in", "r", stdin ) */ map <pair<int, int>, bool> mp; bool bl[ 100001 ]; int d( int x, int y, int xx, int yy ) { return abs( x - xx ) + abs( y - yy ); } int main () { int n; cin >> n; int a, b; pair<int, int> pos; for ( int i = 1; i <= n + n; i ++ ) { cin >> a >> b; mn = oo; for ( int j = 1; j <= n; j ++ ) { for ( int k = 1; k <= 2; k ++ ) { if ( mp[ { j, k } ] ) continue; if ( d( a, b, j, k ) < mn ) { mn = d( a, b, j, k ); pos = { j, k }; } } } mp[ pos ] = 1; ans += mn; } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...