Submission #1071107

# Submission time Handle Problem Language Result Execution time Memory
1071107 2024-08-23T04:50:35 Z Muhammet Palembang Bridges (APIO15_bridge) C++17
22 / 100
30 ms 9176 KB
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define sz(x) (int)x.size()
#define ff first
#define ss second
 
const int N = 300005;
const int M = 1e9 + 7;
 
int T, n, k, s1[N], s2[N];
 
char c1[N], c2[N];
 
signed main(){
	ios::sync_with_stdio(false); cin.tie(0);
 
	cin >> k >> n;
	for(int i = 1; i <= n; i++){
		cin >> c1[i] >> s1[i] >> c2[i] >> s2[i];
	}
 
	if(k == 1){
		int ans = 0;
		vector <int> v;
		for(int i = 1; i <= n; i++){
			if(c1[i] == c2[i]){
				ans += abs(s1[i]-s2[i]);
			}
			else {
				v.push_back(s1[i]);
				v.push_back(s2[i]);
 
			}
		}
		sort(v.begin(), v.end());
		int x = (sz(v)+1)/2;
		x--;
		if(x >= 0) x = v[x];
		for(auto i : v){
			ans += abs(i-x);
		}
		cout << ans+sz(v)/2 << "\n";
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 0 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4692 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4440 KB Output is correct
9 Correct 1 ms 4440 KB Output is correct
10 Correct 1 ms 4440 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 0 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4696 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 15 ms 7420 KB Output is correct
13 Correct 30 ms 9176 KB Output is correct
14 Correct 22 ms 7896 KB Output is correct
15 Correct 20 ms 7120 KB Output is correct
16 Correct 19 ms 8396 KB Output is correct
17 Correct 21 ms 9048 KB Output is correct
18 Correct 26 ms 8652 KB Output is correct
19 Correct 28 ms 9176 KB Output is correct
20 Correct 20 ms 8652 KB Output is correct
21 Correct 26 ms 8908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -