Submission #170332

# Submission time Handle Problem Language Result Execution time Memory
170332 2019-12-24T20:08:21 Z ngmh Preokret (COCI18_preokret) C++11
50 / 50
3 ms 376 KB
#include <bits/stdc++.h>
using namespace std;

typedef pair<long long, long long> pi;

long long a, b, t, l, s, p;
vector<pi> v;
int main(){
	cin >> a;
	for(int i = 0 ; i < a; i++){
		cin >> t;
		v.push_back(pi(t, 0));
	}
	cin >> b;
	for(int i = 0; i < b; i++){
		cin >> t;
		v.push_back(pi(t, 1));
	}
	sort(v.begin(), v.end());
	a = 0; b = 0; t = 0; l = 1440, s = -1;
	for(int i = 0; i < v.size(); i++){
	    if(t == 0 && v[i].first > l) t = a+b;
		if(v[i].second == 1) b++;
		else a++;
		if(a > b && s == 1){ s = 0; p++; }
		if(b > a && s == 0){ s = 1; p++; }
		if(s == -1){
			if(a > b) s = 0;
			else s = 1;
		}
	}
	if(t == 0) t = a+b;
	cout << t << "\n" << p;
}

Compilation message

preokret.cpp: In function 'int main()':
preokret.cpp:21:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < v.size(); i++){
                 ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct