Submission #926914

#TimeUsernameProblemLanguageResultExecution timeMemory
926914AmaarsaaGlobal Warming (CEOI18_glo)C++14
45 / 100
49 ms11600 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long ; const int N = 2e5+ 2; ll a[N], b[N], L[N], R[N]; int main() { // freopen("moocast.in", "r", stdin); // freopen("moocast.out", "w", stdout); ios::sync_with_stdio(false); cin.tie(NULL); ll t, n, m, ans, s, sum, x, mid, y, r, p, i, j, lo, hi; cin >> n >> m; for (i = 1; i <= n; i ++) { cin >> a[i]; b[n - i + 1] = a[i]; } vector < ll > Lda(N, 0); for (i= 1; i <= n; i ++) { lo = 1; hi = N; while ( lo < hi) { mid = (lo + hi)/2; if ( Lda[mid] > b[i]) lo = mid + 1; else hi = mid; } L[n - i + 1] = lo; Lda[lo] = b[i]; } vector < ll > Lca(N, 1e9); for (i = 1; i <= n; i ++) { lo = 1; hi = N; while ( lo < hi) { mid = (lo + hi)/2; if ( Lca[mid] < (a[i] + m)) lo = mid + 1; else hi = mid; } R[i] = lo - 1; lo = 1; hi = N; while ( lo < hi) { mid = (lo + hi)/2; if ( Lca[mid] < a[i]) lo = mid + 1; else hi = mid; } Lca[lo] = a[i]; } ans = 0; for (i= 1; i <= n; i ++) { ans = max(ans, R[i] + L[i]); } cout << ans << endl; }

Compilation message (stderr)

glo.cpp: In function 'int main()':
glo.cpp:13:5: warning: unused variable 't' [-Wunused-variable]
   13 |  ll t, n, m, ans, s, sum, x, mid, y, r, p, i, j, lo, hi;
      |     ^
glo.cpp:13:19: warning: unused variable 's' [-Wunused-variable]
   13 |  ll t, n, m, ans, s, sum, x, mid, y, r, p, i, j, lo, hi;
      |                   ^
glo.cpp:13:22: warning: unused variable 'sum' [-Wunused-variable]
   13 |  ll t, n, m, ans, s, sum, x, mid, y, r, p, i, j, lo, hi;
      |                      ^~~
glo.cpp:13:27: warning: unused variable 'x' [-Wunused-variable]
   13 |  ll t, n, m, ans, s, sum, x, mid, y, r, p, i, j, lo, hi;
      |                           ^
glo.cpp:13:35: warning: unused variable 'y' [-Wunused-variable]
   13 |  ll t, n, m, ans, s, sum, x, mid, y, r, p, i, j, lo, hi;
      |                                   ^
glo.cpp:13:38: warning: unused variable 'r' [-Wunused-variable]
   13 |  ll t, n, m, ans, s, sum, x, mid, y, r, p, i, j, lo, hi;
      |                                      ^
glo.cpp:13:41: warning: unused variable 'p' [-Wunused-variable]
   13 |  ll t, n, m, ans, s, sum, x, mid, y, r, p, i, j, lo, hi;
      |                                         ^
glo.cpp:13:47: warning: unused variable 'j' [-Wunused-variable]
   13 |  ll t, n, m, ans, s, sum, x, mid, y, r, p, i, j, lo, hi;
      |                                               ^
#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...