Submission #1037826

# Submission time Handle Problem Language Result Execution time Memory
1037826 2024-07-29T08:57:05 Z Muhammet Palembang Bridges (APIO15_bridge) C++17
0 / 100
1 ms 604 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define sz(x) (int)x.size()
#define ff first
#define ss second

const ll N = 300005;
const ll M = 1e9 + 7;

int T, n, k;

vector <int> v1, v2;

int main(){
	ios::sync_with_stdio(false); cin.tie(0);

	cin >> k >> n;
	for(int i = 1; i <= n; i++){
		char c1, c2;
		int s1, s2;
		cin >> c1 >> s1 >> c2 >> s2;
		if(c1 == 'A') v1.push_back(s1);
		else v2.push_back(s1);
		if(c2 == 'A') v1.push_back(s2);
		else v2.push_back(s2);
	}

	sort(v1.begin(), v1.end());
	sort(v2.begin(), v2.end());
	ll x = v1[0], ans = 0;
	for(int i = 0; i < sz(v1); i++){
		ans += (abs(v1[i]-x));
		ans += (abs(v2[i]-x));
	}
	cout << ans;

	return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -