답안 #28246

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
28246 2017-07-16T04:08:29 Z :thinking_face:(#1137, zych1751, Acka, suzy) Play Onwards (FXCUP2_onward) C++11
0 / 1
36 ms 11784 KB
#include <bits/stdc++.h>

using namespace std;

bool not_prime[5000000];
long long score[2];
bool visited[5000000];

int main ()
{
	not_prime[0] = not_prime[1] = false;
	for(int i = 2; i < 5000000; i++)
	{
		if(not_prime[i])	continue;
		for(int j = i*2; j < 5000000; j += i)
			not_prime[j] = true;
	}

	int n;
	scanf("%d", &n);

	priority_queue<int> pq[2];
	int cur = 0; // 0 : ���
	for(int i = 0; i < n*2; i++, cur^=1)
	{
		int a, net=cur^1;
		scanf("%d", &a);
		if(not_prime[a])
		{
			if(pq[net].size() < 3)
				score[net] += 1000;
			else
			{
				int a, b;
				a = pq[net].top();	pq[net].pop();
				b = pq[net].top();	pq[net].pop();
				score[net] += pq[net].top();
				pq[net].push(a);
				pq[net].push(b);
			}
		}
		else if(visited[a])
			score[cur] -= 1000;
		else
		{
			visited[a] = true;
			pq[cur].push(a);
		}
	}

	if(score[0] > score[1])
		printf("�Ҽ��� �� �����\n");
	else if(score[0] == score[1])
		printf("�쿭�� ���� �� ����\n");
	else
		printf("�Ҽ� ������ ���Լ�\n");
    return 0;
}

Compilation message

onward.cpp: In function 'int main()':
onward.cpp:20:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
onward.cpp:27:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a);
                  ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 36 ms 11784 KB Output isn't correct
2 Halted 0 ms 0 KB -