Submission #878828

#TimeUsernameProblemLanguageResultExecution timeMemory
878828niterCoin Collecting (JOI19_ho_t4)C++14
0 / 100
980 ms596 KiB
#include <bits/stdc++.h> #define pb push_back #define ins isnert #define pii pair<int,int> #define ff first #define ss second #define loop(i,a,b) for(int i = (a); i < (b); i ++) #define op(x) cerr << #x << " = " << x << endl; #define opa(x) cerr << #x << " = " << x << ", "; #define ops(x) cerr << x; #define spac cerr << ' '; #define entr cerr << endl; #define STL(x) cerr << #x << " : "; for(auto &qwe:x) cerr << qwe << ' '; cerr << endl; #define ARR(x, nnn) cerr << #x << " : "; loop(qwe,0,nnn) cerr << x[qwe] << ' '; cerr << endl; #define BAE(x) (x).begin(), (x).end() #pragma GCC optimize("O3") using namespace std; typedef long long ll; mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); pii a[30], b[30]; int main(){ int n, m; cin >> n; m = n << 1; loop(i,0,m) cin >> a[i].ff >> a[i].ss; loop(i,0,n){ b[i] = {i + 1, 1}; b[i + n] = {i + 1, 2}; } sort(b, b + m); long long ans = (ll)(1e18), tmp; do{ shuffle(b, b + m, RNG); tmp = 0; loop(i,0,m){ tmp += abs(a[i].ff - b[i].ff); tmp += abs(a[i].ss - b[i].ss); } ans = min(ans, tmp); }while((long double)clock() / CLOCKS_PER_SEC <= 0.98); cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...