Submission #411854

# Submission time Handle Problem Language Result Execution time Memory
411854 2021-05-26T06:48:14 Z 장태환(#7564) Pastiri (COI20_pastiri) C++17
8 / 100
191 ms 16380 KB
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int dp[2000100];
int bef2[200100];
int main()
{
	int N, K;
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N >> K;
	int i;
	vector<int>x;
	dp[1] = N;
	for (i = 1; i < N; i++)
	{
		dp[i + 1] = N;
		int a, b;
		cin >> a >> b;
	}
	for (i = 0; i < K; i++)
	{
		
		int a;
		cin >> a;
		x.push_back(a);
	}
	sort(x.begin(), x.end());
	for (i = 0; i < K; i++)
	{
		dp[i + 1] = min(dp[i + 1], dp[i]);
		if (i != K - 1 && x[i] % 2 == x[i + 1] % 2)
		{
			bef2[i + 2] = 1;
			dp[i + 2] = min(dp[i + 2], dp[i]);
		}
	}
	int cur = K;
	vector<int>an;
	while (cur)
	{
		if (bef2[cur])
		{
			an.push_back((x[cur - 1] + x[cur - 2]) / 2);
			cur -= 2;
		}
		else
		{
			an.push_back((x[cur - 1]));
			cur--;
		}
	}
	cout << an.size() << '\n';
	for (i = 0; i < an.size(); i++)
	{
		cout << an[an.size()-i-1] << ' ';
	}
}

Compilation message

pastiri.cpp: In function 'int main()':
pastiri.cpp:55:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |  for (i = 0; i < an.size(); i++)
      |              ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 103 ms 8900 KB Output is correct
2 Correct 113 ms 8860 KB Output is correct
3 Correct 102 ms 8924 KB Output is correct
4 Correct 191 ms 16380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Sheep 3030 not protected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Sheep 86 not protected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 109 ms 9044 KB Sheep 54 not protected
2 Halted 0 ms 0 KB -