Submission #253191

#TimeUsernameProblemLanguageResultExecution timeMemory
253191NightlightRabbit Carrot (LMIO19_triusis)C++14
100 / 100
43 ms4084 KiB
#include <bits/stdc++.h> using namespace std; int N; long long A[200005], M; vector<long long> LIS; int main() { scanf("%d %lld", &N, &M); for(int i = 1; i <= N; i++) { scanf("%lld", &A[i]); A[i] = i * M - A[i]; // cout << A[i] << " "; } // cout << "\n"; int pos; for(int i = 1; i <= N; i++) { if(A[i] < 0) continue; if(LIS.empty()) { LIS.emplace_back(A[i]); }else { pos = upper_bound(LIS.begin(), LIS.end(), A[i]) - LIS.begin(); if(pos == LIS.size()) LIS.emplace_back(A[i]); else LIS[pos] = A[i]; } } printf("%d\n", N - LIS.size()); }

Compilation message (stderr)

triusis.cpp: In function 'int main()':
triusis.cpp:23:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       if(pos == LIS.size()) LIS.emplace_back(A[i]);
          ~~~~^~~~~~~~~~~~~
triusis.cpp:27:32: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<long long int>::size_type {aka long unsigned int}' [-Wformat=]
   printf("%d\n", N - LIS.size());
                  ~~~~~~~~~~~~~~^
triusis.cpp:9:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %lld", &N, &M);
   ~~~~~^~~~~~~~~~~~~~~~~~~
triusis.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld", &A[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...