Submission #282765

#TimeUsernameProblemLanguageResultExecution timeMemory
282765dooweyGlobal Warming (CEOI18_glo)C++14
47 / 100
68 ms8748 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pii; #define fi first #define se second #define mp make_pair #define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); const ll inf = (ll)1e10; int main(){ fastIO; int n; ll x; cin >> n >> x; vector<ll> v(n); for(int i = 0 ; i < n; i ++ ){ cin >> v[i]; } vector<int> g; vector<pii> nx; int res = 1; int mid, l, r; int sh; for(int i = n-1; i >= 0 ; i -- ){ sh = v[i]; l = 0, r = (int)g.size(); while(l < r){ mid = (l + r) / 2; if(g[mid] <= sh) r = mid; else l = mid + 1; } if(l == g.size()){ nx.push_back(mp(sh, -1)); g.push_back(sh); } else{ nx.push_back(mp(g[l], l)); g[l]=sh; } } vector<int> cc; int nl, nr; int id; for(int i = 0 ; i < n; i ++ ){ if(nx.back().se == -1){ g.pop_back(); } else{ g[nx.back().se] = nx.back().fi; } nx.pop_back(); sh = v[i]-x; l=0,r=cc.size(); while(l < r){ mid = (l + r) / 2; if(cc[mid] < sh) l = mid + 1; else r = mid; } id = l; if(id == cc.size()){ cc.push_back(sh); } else{ cc[id] = sh; } l = 0, r = g.size(); while(l + 1 < r){ mid = (l + r) / 2; if(g[mid] > sh) l = mid; else r = mid; } res = max(res, (id+1)+l+(g[l]>sh)); } cout << res << "\n"; return 0; }

Compilation message (stderr)

glo.cpp: In function 'int main()':
glo.cpp:39:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         if(l == g.size()){
      |            ~~^~~~~~~~~~~
glo.cpp:69:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |         if(id == cc.size()){
      |            ~~~^~~~~~~~~~~~
glo.cpp:49:9: warning: unused variable 'nl' [-Wunused-variable]
   49 |     int nl, nr;
      |         ^~
glo.cpp:49:13: warning: unused variable 'nr' [-Wunused-variable]
   49 |     int nl, nr;
      |             ^~
#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...