Submission #200555

# Submission time Handle Problem Language Result Execution time Memory
200555 2020-02-07T08:27:48 Z Kalam Studentsko (COCI14_studentsko) C++11
100 / 100
8 ms 892 KB
// KALAM
# include<bits/stdc++.h>

# define debug(x) cerr << #x << " = " << x << endl

using namespace std;

const int N = 100000 + 77;
int A , n , k , a[N] , F[N];
vector < int > U;
int main() {
   memset(F , 63 , sizeof F);
   scanf("%d %d" , & n , & k);
   for(int i = 1;i <= n;++ i)
      scanf("%d" , a + i) , U.push_back(a[i]);
   sort(U.begin() , U.end());
   U.resize(unique(U.begin() , U.end()) - U.begin());
   for(int i = 1;i <= n;++ i)
      a[i] = (lower_bound(U.begin() , U.end() , a[i]) - U.begin()) / k + 1;
   F[0] = -1;
   for(int i = 1;i <= n;++ i) {
      int id = upper_bound(F , F + n + 2 , a[i]) - F;
      F[id] = a[i];
      A = max(A , id);
   }
   printf("%d\n" , n - A);
	return 0;
}

Compilation message

studentsko.cpp: In function 'int main()':
studentsko.cpp:13:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d %d" , & n , & k);
    ~~~~~^~~~~~~~~~~~~~~~~~~~~
studentsko.cpp:15:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%d" , a + i) , U.push_back(a[i]);
       ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 632 KB Output is correct
2 Correct 5 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 760 KB Output is correct
2 Correct 5 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 760 KB Output is correct
2 Correct 5 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 760 KB Output is correct
2 Correct 7 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 760 KB Output is correct
2 Correct 7 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 760 KB Output is correct
2 Correct 7 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 888 KB Output is correct
2 Correct 7 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 892 KB Output is correct
2 Correct 7 ms 888 KB Output is correct