Submission #1119288

#TimeUsernameProblemLanguageResultExecution timeMemory
1119288hamzabcGlobal Warming (CEOI18_glo)C++14
100 / 100
180 ms40908 KiB
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define mod 1000000007 #define sp << " " << #define endl << '\n' class lazyporp{ private: vector<long long int> lazy; vector<pair<long long int, long long int>> tree; void push(int node){ if (node >= lazy.size()) return; if (lazy[node]){ tree[node].first = tree[node].second = lazy[node]; if (((node << 1) | 1) < lazy.size()) lazy[node << 1] = lazy[(node << 1) | 1] = lazy[node]; lazy[node] = 0; } } void _update(int say, int at, int l, int r, int s){ push(s); push(s << 1); push((s << 1) | 1); int m = (l + r) >> 1; if (at == -1){ if (l == r){ tree[s].first = tree[s].second = say; return; } if (tree[s << 1].second >= say){ _update(say, at, l, m, s << 1); }else{ _update(say, at, m + 1, r, (s << 1) | 1); } }else{ if (tree[s].first >= say && at >= r){ tree[s].first = tree[s].second = lazy[s] = say; return; } if (l == r){ tree[s].first = tree[s].second = say; return; } if (tree[s << 1].second >= say){ _update(say, at, l, m, s << 1); if (at > m) _update(say, at, m + 1, r, (s << 1) | 1); }else{ _update(say, at, m + 1, r, (s << 1) | 1); } } tree[s].first = tree[s << 1].first; tree[s].second = tree[(s << 1) | 1].second; } long long int _count(int l, int r, int s){ push(s); if (tree[s].second != LONG_MAX) return r - l + 1; if (tree[s].first == LONG_MAX) return 0; int m = (l + r) >> 1; return _count(l, m, s << 1) + _count(m + 1, r, (s << 1) | 1); } public: void init(){ lazy.resize(1600000); tree.resize(1600000, { LONG_MAX, LONG_MAX }); } void update(int say){ _update(say, -1, 0, 200000, 1); } void update(int say, int at){ _update(say, at, 0, 200000, 1); } long long int count(){ return _count(0, 200000, 1); } }; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long int N, D; lazyporp LISmanuplated; vector<long long int> LISnormal; LISmanuplated.init(); LISmanuplated.update(0); LISnormal.push_back(0); cin >> N >> D; for (int i = 0; i < N; i++){ long long int in; cin >> in; auto k = lower_bound(all(LISnormal), in + D); LISmanuplated.update(in, k - LISnormal.begin()); k = lower_bound(all(LISnormal), in); if (k == LISnormal.end()){ LISnormal.push_back(in); }else{ *k = in; } LISmanuplated.update(in); } cout << LISmanuplated.count() - 1; return 0; }

Compilation message (stderr)

glo.cpp: In member function 'void lazyporp::push(int)':
glo.cpp:18:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |   if (node >= lazy.size())
      |       ~~~~~^~~~~~~~~~~~~~
glo.cpp:22:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |    if (((node << 1) | 1) < lazy.size())
      |        ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...