Submission #1120754

#TimeUsernameProblemLanguageResultExecution timeMemory
1120754InvMODRabbit Carrot (LMIO19_triusis)C++14
100 / 100
37 ms7020 KiB
#include<bits/stdc++.h> #define int long long using namespace std; int lis(vector<int>& potential){ vector<int> lis_; for(int i = 0; i < (int)potential.size(); i++){ if(!lis_.size()){ lis_.push_back(potential[i]); } else{ int p = upper_bound(lis_.begin(), lis_.end(), potential[i]) - lis_.begin(); if(p == lis_.size()){ lis_.push_back(potential[i]); } else{ lis_[p] = potential[i]; } } } return lis_.size(); } void solve() { int n,w; cin >> n >> w; vector<int> potential; for(int i = 1; i <= n; i++){ int x; cin >> x; if(x <= 1ll * i * w){ potential.push_back(i * w - x); } } cout << n - lis(potential) <<"\n"; } int32_t main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define name "InvMOD" if(fopen(name".INP", "r")){ freopen(name".INP", "r", stdin); freopen(name".OUT", "w", stdout); } solve(); return 0; }

Compilation message (stderr)

triusis.cpp: In function 'long long int lis(std::vector<long long int>&)':
triusis.cpp:16:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |             if(p == lis_.size()){
      |                ~~^~~~~~~~~~~~~~
triusis.cpp: In function 'int32_t main()':
triusis.cpp:48:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |         freopen(name".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
triusis.cpp:49:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   49 |         freopen(name".OUT", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...