| Task: | Lista |
| Sender: | OorigamiK |
| Submission time: | 2026-01-17 16:58:33 +0200 |
| Language: | C++ (C++20) |
| Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'void printList(std::vector<int>)':
input/code.cpp:6:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
6 | for (int i=0;i<A.size();i++){
| ~^~~~~~~~~
input/code.cpp: In function 'int main()':
input/code.cpp:88:24: error: 'current' was not declared in this scope; did you mean 'correct'?
88 | for (int i=choices+current;i<n;i++){
| ^~~~~~~
| correct
input/code.cpp:94:35: error: 'current' was not declared in this scope; did you mean 'correct'?
94 | if (sortedList[min(n, choices+current)-1])
| ^~~~~~~
| correctCode
#include <bits/stdc++.h>
using namespace std;
void printList(vector<int> A){
for (int i=0;i<A.size();i++){
cout<<A[i]<<" ";
}
cout<<"\n";
}
int main(){
int n, k;
cin>>n>>k;
vector<int> list(n);
for (int i=0;i<n;i++){
int a;
cin>>a;
list[i]=a;
}
vector<int> sortedList=list;
sort(sortedList.begin(), sortedList.end());
vector<int> numList(n);
int iter1=0;
int iter2=1;
int num=1;
while(iter2<n){
if (sortedList[iter2]==sortedList[iter1] && iter2!=n-1){
num++;
}
else{
if (iter2==n-1){
iter2++;
num++;
}
for (int i=iter1;i<iter2;i++){
numList[i]=num;
}
iter1=iter2;
num=1;
}
iter2++;
}
printList(sortedList);
//printList(numList);
int choices=k;
while (true){
int count=0;
int correct=0;
for (int i=0;i<min(choices+correct, n);i++){
if (list[i]==sortedList[i]){
correct++;
continue;
}
if (list[i]>sortedList[choices-1]){
count++;
}
}
if (count==0){
for (int i=choices+correct;i<n;i++){
if (list[i]<sortedList[choices-1]){
count++;
}
}
choices-=count;
break;
}
else{
choices-=count;
}
}
cout<<choices<<"\n";
int correct=0;
for (int i=0;i<choices+correct;i++){
if (list[i]==sortedList[i]){
correct++;
}
}
vector<bool> toSwap(n);
for (int i=0;i<min(n, choices+correct);i++){
if (list[i]!=sortedList[i]){
toSwap[i]=true;
}
}
for (int i=choices+current;i<n;i++){
if (list[i]<sortedList[min(choices+correct, n)-1]){
toSwap[i]=true;
}
}
if (sortedList[min(n, choices+current)-1])
return 0;
} 