Submission #1116053

#TimeUsernameProblemLanguageResultExecution timeMemory
1116053Dan4LifeCoin Collecting (JOI19_ho_t4)C++17
0 / 100
2 ms2640 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include <bits/stdc++.h> using namespace std; #define pb push_back #define sz(a) (int)a.size() #define all(a) begin(a),end(a) #define int long long const int N = (int)1e5+10; int n; vector<int> v[N]; int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; int ans = 0; for(int i = 0; i < 2*n; i++){ int x, y; cin >> x >> y; v[1].pb(x), v[0].pb(y); } for(int j : {0,1}) sort(all(v[j])); int x = 1; for(int i = 0; i < 2*n; i++){ if(i<n) ans+=abs(v[0][i]-1)+abs(x-v[1][i]); else ans+=abs(v[0][i]-2)+abs(x-v[1][i]); if(i%2) x++; } cout << ans << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...