Submission #866767

#TimeUsernameProblemLanguageResultExecution timeMemory
866767tienbinhRabbit Carrot (LMIO19_triusis)C++14
63 / 100
22 ms6076 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define name "" #define all(x) x.begin(), x.end() const int N = 1e5 + 7; long long b[N], M, a[N]; using ll = long long; int n; basic_string <ll> compress, v; struct BIT{ long long bit[N]; BIT() {memset(bit, 0, sizeof bit);} void upd(int x, long long val){ for(; x < N ; x += (x & - x)) bit[x] = max(bit[x], val); } long long get(int x){ long long ans = 0; for(; x >= 1; x -= (x & - x)) ans = max(ans, bit[x]); return ans; } }bit; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); if(fopen("bug.inp", "r")) freopen("bug.inp", "r", stdin), freopen("bug.out", "w", stdout); else if (fopen(name".inp", "r")) freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout); cin >> n >> M; for(int i = 1; i <= n ; i++){ cin >> a[i]; if(i * M >= a[i]) v += (i * M - a[i]), compress += (i * M - a[i]); } sort(all(compress)); compress.erase(unique(all(compress)), compress.end()); for(int i = 0; i < v.size() ; i++) v[i] = lower_bound(all(compress), v[i]) - compress.begin() + 1; long long ans = 0; for(int it : v){ long long tmp = bit.get(it) + 1; ans = max(ans, tmp); bit.upd(it, tmp); } cout << n - ans; return 0; }

Compilation message (stderr)

triusis.cpp: In function 'int main()':
triusis.cpp:39:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for(int i = 0; i < v.size() ; i++)
      |                    ~~^~~~~~~~~~
triusis.cpp:29:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         freopen("bug.inp", "r", stdin), freopen("bug.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
triusis.cpp:29:48: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         freopen("bug.inp", "r", stdin), freopen("bug.out", "w", stdout);
      |                                         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
triusis.cpp:31:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |         freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
triusis.cpp:31:49: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |         freopen(name".inp", "r", stdin), 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...