답안 #257766

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
257766 2020-08-04T18:07:47 Z HAjrhsa Preokret (COCI18_preokret) C++17
50 / 50
2 ms 384 KB
#include <bits/stdc++.h>
using namespace std;

void fst()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
#endif
}
int pa[2881], pb[2881];
#define int long long
int32_t main()
{
	//fst();
	int a, b;
	cin >> a ;
	int x;
	while (a--)
	{
		cin >> x;
		pa[x]++;
	}
	cin>>b;
	while (b--)
	{
		cin >> x;
		pb[x]++;
	}
	int prev = 0, turn = 0;
	for (int i = 1; i <= 2880; i++)
	{
		pa[i]+=pa[i-1];
		pb[i]+=pb[i-1];
		if (prev == 0)
		{
			if (pa[i] > pb[i])
				prev = 1;
			else if (pa[i] < pb[i])
				prev = 2;
		}
		if(prev==1 && pa[i]<pb[i]){prev=2;turn++;}
		if(prev==2 && pa[i]>pb[i]){prev=1;turn++;}
	}

	cout<<pa[1440]+pb[1440]<<"\n"<<turn<<"\n";
}

Compilation message

preokret.cpp: In function 'void fst()':
preokret.cpp:9:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen("input.txt", "r", stdin);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct