Submission #113140

# Submission time Handle Problem Language Result Execution time Memory
113140 2019-05-24T01:38:19 Z luciocf Studentsko (COCI14_studentsko) C++14
100 / 100
5 ms 736 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 5e3+10;

int n;
int a[maxn], aux[maxn];

int lis(void)
{
	vector<int> v;

	for (int i = 1; i <= n; i++)
	{
		vector<int>::iterator it = upper_bound(v.begin(), v.end(), a[i]);

		if (it == v.end())
			v.push_back(a[i]);
		else
			*it = a[i];
	}

	return v.size();
}

int main(void)
{
	int k;
	scanf("%d %d", &n, &k);

	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);

		aux[i] = a[i];
	}

	sort(aux+1, aux+n+1);

	map<int, int> group;

	for (int i = 1; i <= n; i++)
		group[aux[i]] = (i-1)/k;

	for (int i = 1; i <= n; i++)
		a[i] = group[a[i]];

	printf("%d\n", n-lis());
}

Compilation message

studentsko.cpp: In function 'int main()':
studentsko.cpp:30:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &k);
  ~~~~~^~~~~~~~~~~~~~~~~
studentsko.cpp:34:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i]);
   ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 640 KB Output is correct
2 Correct 4 ms 736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 640 KB Output is correct
2 Correct 5 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 640 KB Output is correct
2 Correct 4 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 640 KB Output is correct
2 Correct 4 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 640 KB Output is correct
2 Correct 4 ms 640 KB Output is correct