Submission #321580

# Submission time Handle Problem Language Result Execution time Memory
321580 2020-11-12T19:35:16 Z binary_python Palembang Bridges (APIO15_bridge) C++14
22 / 100
288 ms 16224 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;


#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using Tree= tree<T, null_type, less<T>,rb_tree_tag, tree_order_statistics_node_update>;

int main() {
	int k,n;
	cin >> k >> n;
	if (k==1) {
		ll ans = 0; 
		vector<int> nums;
		Tree<pair<int,int>> ms;
		int c=0;
		for (int i=0; i<n; i++) {
			char p,q; int s,t;
			cin >> p >> s >> q >> t;
			if (p == q) {
				ans += abs(t-s);
			}
			else {
				nums.push_back(s);
				nums.push_back(t);
				ms.insert({s,i}); ms.insert({t,i+n});
				c+=2;
			}
		}
		int median = ms.find_by_order(c/2)->first;
		for (int z : nums) {ans += abs(z-median);}
		ans += (c/2);
		cout << ans << "\n";
	}
	
	
	
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 492 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 3 ms 492 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 2 ms 492 KB Output is correct
10 Correct 2 ms 512 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 2 ms 492 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 2 ms 492 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 2 ms 492 KB Output is correct
10 Correct 4 ms 492 KB Output is correct
11 Correct 2 ms 492 KB Output is correct
12 Correct 153 ms 14432 KB Output is correct
13 Correct 288 ms 16060 KB Output is correct
14 Correct 222 ms 13536 KB Output is correct
15 Correct 148 ms 9828 KB Output is correct
16 Correct 181 ms 15456 KB Output is correct
17 Correct 208 ms 15956 KB Output is correct
18 Correct 207 ms 15712 KB Output is correct
19 Correct 233 ms 16224 KB Output is correct
20 Correct 193 ms 15520 KB Output is correct
21 Correct 184 ms 15712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -