Submission #942204

# Submission time Handle Problem Language Result Execution time Memory
942204 2024-03-10T10:52:50 Z artixkrishna Studentsko (COCI14_studentsko) C++14
100 / 100
3 ms 900 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:31:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |  scanf("%d %d", &n, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~~
studentsko.cpp:35:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |   scanf("%d", &a[i]);
      |   ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 900 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 2 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 600 KB Output is correct
2 Correct 2 ms 604 KB Output is correct