Submission #1116053

# Submission time Handle Problem Language Result Execution time Memory
1116053 2024-11-21T08:19:25 Z Dan4Life Coin Collecting (JOI19_ho_t4) C++17
0 / 100
2 ms 2640 KB
#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 time Memory Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 2 ms 2640 KB Output is correct
4 Correct 2 ms 2640 KB Output is correct
5 Correct 2 ms 2640 KB Output is correct
6 Incorrect 2 ms 2640 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 2 ms 2640 KB Output is correct
4 Correct 2 ms 2640 KB Output is correct
5 Correct 2 ms 2640 KB Output is correct
6 Incorrect 2 ms 2640 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 2 ms 2640 KB Output is correct
4 Correct 2 ms 2640 KB Output is correct
5 Correct 2 ms 2640 KB Output is correct
6 Incorrect 2 ms 2640 KB Output isn't correct
7 Halted 0 ms 0 KB -