Submission #368189

#TimeUsernameProblemLanguageResultExecution timeMemory
368189_martynasRabbit Carrot (LMIO19_triusis)C++11
100 / 100
34 ms4196 KiB
#include <bits/stdc++.h> using namespace std; const int MAX_N = 2e5+5; int n, m; int Arr[MAX_N]; int main() { scanf("%d%d", &n, &m); for(int i = 0; i < n; i++) { scanf("%d", &Arr[i]); Arr[i] = (i + 1) * m - Arr[i]; } vector<int> tail; for(int i = 0; i < n; i++) { if(Arr[i] < 0) continue; auto it = upper_bound(tail.begin(), tail.end(), Arr[i]); if(it == tail.end()) { tail.push_back(Arr[i]); } else { *it = Arr[i]; } } printf("%d", n - tail.size()); return 0; } /* INPUT 5 400 300 700 200 1000 500 3 300 700 1000 1300 */

Compilation message (stderr)

triusis.cpp: In function 'int main()':
triusis.cpp:36:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   36 |     printf("%d", n - tail.size());
      |             ~^   ~~~~~~~~~~~~~~~
      |              |     |
      |              int   std::vector<int>::size_type {aka long unsigned int}
      |             %ld
triusis.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |     scanf("%d%d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~
triusis.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |         scanf("%d", &Arr[i]);
      |         ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...