Submission #684298

#TimeUsernameProblemLanguageResultExecution timeMemory
684298sz1218Rabbit Carrot (LMIO19_triusis)C++14
0 / 100
0 ms212 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pi; typedef vector<int> vi; int __i__, __j__; #define printVar(n) cout<<#n<<": "<<n<<endl #define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl #define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;} #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define F0R(i,a) FOR(i,0,a) #define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i) #define R0F(i,a) ROF(i,0,a) const int NN = 2e5+2, mod = 1e9 + 7; int n, m; vi dp, a; bool comp(const int &x, const int &y){ return a[y] - a[x] <= (y-x)*m; } int lis(vi a){ vi dp; for(int i=0;i<=n;i++){ int pos = lower_bound(dp.begin(), dp.end(), i, comp) - dp.begin(); if(pos == dp.size()){ dp.push_back(i); } else if(pos != 0){ dp[pos] = i; } printArr(dp, dp.size()); cout << "\n"; } return dp.size(); } int main() { cin >> n >> m; a.resize(n+1); for(int i=1;i<=n;i++)cin >> a[i]; cout << n+1 - lis(a) << endl; //cout << comp(a[2], a[3]); return 0; }

Compilation message (stderr)

triusis.cpp: In function 'int lis(vi)':
triusis.cpp:30:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         if(pos == dp.size()){
      |            ~~~~^~~~~~~~~~~~
triusis.cpp:10:55: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 | #define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
      |                                                  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   11 | #define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   12 | 
      |                                                        
   13 | #define FOR(i,a,b) for (int i = (a); i < (b); ++i)
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     
   14 | #define F0R(i,a) FOR(i,0,a)
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~                            
   15 | #define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
   16 | #define R0F(i,a) ROF(i,0,a)
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~                            
   17 | 
      |                                                        
   18 | const int NN = 2e5+2, mod = 1e9 + 7;
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                   
   19 | int n, m;
      | ~~~~~~~~~                                              
   20 | vi dp, a;
      | ~~~~~~~~~                                              
   21 | 
      |                                                        
   22 | bool comp(const int &x, const int &y){
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                 
   23 |     return a[y] - a[x] <= (y-x)*m;
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                     
   24 | }
      | ~                                                      
   25 | 
      |                                                        
   26 | int lis(vi a){
      | ~~~~~~~~~~~~~~                                         
   27 |     vi dp;
      |     ~~~~~~                                             
   28 |     for(int i=0;i<=n;i++){
      |     ~~~~~~~~~~~~~~~~~~~~~~                             
   29 |         int pos = lower_bound(dp.begin(), dp.end(), i, comp) - dp.begin();
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   30 |         if(pos == dp.size()){
      |         ~~~~~~~~~~~~~~~~~~~~~                          
   31 |             dp.push_back(i);
      |             ~~~~~~~~~~~~~~~~                           
   32 |         }
      |         ~                                              
   33 |         else if(pos != 0){
      |         ~~~~~~~~~~~~~~~~~~                             
   34 |             dp[pos] = i;
      |             ~~~~~~~~~~~~                               
   35 |         }
      |         ~                                              
   36 |         printArr(dp, dp.size()); cout << "\n";
      |         ~~~~~~~~~~~~~~~~~~~~~~                         
triusis.cpp:36:9: note: in expansion of macro 'printArr'
   36 |         printArr(dp, dp.size()); cout << "\n";
      |         ^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...