답안 #171282

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
171282 2019-12-28T07:29:17 Z Su1tan Preokret (COCI18_preokret) C++14
50 / 50
6 ms 380 KB
#include <bits/stdc++.h>
using namespace std;

#define sz size
#define pb push_back

const int N = 3e3 + 123;

int n, m, a, b, ans1, ans, l;
map <int, bool> team;
vector <int> v;
int main() {
	//freopen("input.txt", "r", stdin);
	cin >> n;
	for(int i = 1; i <= n; ++i) {
		int k;
		cin >> k;
		v.pb(k);
		if(k <= 1440) ++ans1;
		team[k] = 0;
	}
	cin >> m;
	for(int i = 1; i <= m; ++i) {
		int k;
		cin >> k;
		if(k <= 1440) ++ans1;
		v.pb(k);
		team[k] = 1;
	}
	cout << ans1 << "\n";
	sort(v.begin(), v.end());
	if(team[v[0]] == 0) {
		l = 0;
		++a;
	}
	else {
		l = 1;
		++b;
	}
	for(int i = 1; i < v.sz(); ++i) {
		if(!team[v[i]]) ++a;
		else ++b;
		if(a > b && l == 1 && b != 0) {
			l = 0;
			++ans;
		}
		if(a < b && l == 0 && a != 0) {
			l = 1;
			++ans;
		}
	}
	cout << ans;
}

Compilation message

preokret.cpp: In function 'int main()':
preokret.cpp:40:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 1; i < v.sz(); ++i) {
                 ~~^~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 6 ms 376 KB Output is correct
7 Correct 4 ms 376 KB Output is correct
8 Correct 4 ms 380 KB Output is correct
9 Correct 4 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct