Submission #85925

# Submission time Handle Problem Language Result Execution time Memory
85925 2018-11-22T20:07:41 Z memetkagan44 Studentsko (COCI14_studentsko) C++11
100 / 100
6 ms 1956 KB
#include<bits/stdc++.h>
using namespace std;
int n,k,ar[5001];
vector<int> ans;
vector<pair<int,int> > v;
int main(){
    scanf("%d %d",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%d",&ar[i]);
        v.push_back(make_pair(ar[i],i));
    }
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++)
        ar[v[i].second]=(i/k)+1;
    ans.push_back(-0x3f3f3f3f);
    for(int i=0;i<n;i++){
        vector<int>::iterator it=upper_bound(ans.begin(),ans.end(),ar[i]);
        if(it==ans.end())
            ans.push_back(ar[i]);
        else
            *it=ar[i];
    }
    printf("%d\n",n+1-ans.size());
    return 0;
}

Compilation message

studentsko.cpp: In function 'int main()':
studentsko.cpp:23:33: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
     printf("%d\n",n+1-ans.size());
                   ~~~~~~~~~~~~~~^
studentsko.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&n,&k);
     ~~~~~^~~~~~~~~~~~~~~
studentsko.cpp:9:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&ar[i]);
         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 552 KB Output is correct
2 Correct 2 ms 552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 608 KB Output is correct
2 Correct 2 ms 652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1380 KB Output is correct
2 Correct 4 ms 1380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1472 KB Output is correct
2 Correct 4 ms 1512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1712 KB Output is correct
2 Correct 4 ms 1744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1808 KB Output is correct
2 Correct 4 ms 1860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1908 KB Output is correct
2 Correct 6 ms 1956 KB Output is correct