Submission #1269030

#TimeUsernameProblemLanguageResultExecution timeMemory
1269030sealsarecoolRabbit Carrot (LMIO19_triusis)C++20
0 / 100
2 ms328 KiB
#include <bits/stdc++.h> using namespace std; int main() { int N,M; cin>>N>>M; long long pillars[N+1]; memset(pillars,0,sizeof(pillars)); int ans = 0; for(int i = 0;i<=N;i++){ int x; cin>>x; pillars[i] = x-M*(i); } vector<long long>dp(N+1,-1e20); dp[0] = 1e20; for (int i = 0; i < N; i++) { int l = upper_bound(dp.begin(), dp.end(), pillars[i],greater<int>()) - dp.begin(); if(l==1&&pillars[i]>M*(i+1)){ continue; } if (dp[l-1] >= pillars[i] && pillars[i] >= dp[l]) dp[l] = pillars[i]; } for (int l = 0; l <= N; l++) { if (dp[l] > -1e20) ans = l; } cout<<N-ans; }

Compilation message (stderr)

triusis.cpp: In function 'int main()':
triusis.cpp:16:27: warning: overflow in conversion from 'double' to 'std::vector<long long int>::value_type' {aka 'long long int'} changes value from '-1.0e+20' to '-9223372036854775808' [-Woverflow]
   16 |   vector<long long>dp(N+1,-1e20);
      |                           ^~~~~
triusis.cpp:17:11: warning: overflow in conversion from 'double' to '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} changes value from '1.0e+20' to '9223372036854775807' [-Woverflow]
   17 |   dp[0] = 1e20;
      |           ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...