제출 #741234

#제출 시각아이디문제언어결과실행 시간메모리
741234blackslexGlobal Warming (CEOI18_glo)C++17
52 / 100
51 ms5716 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; const int N = 2e5 + 5; ll n, k, a[N], b[N], ans; vector<ll> v, u; int main() { scanf("%lld %lld", &n, &k); for (int i = 1; i <= n; i++) scanf("%lld", &a[i]); for (int i = 1; i <= n; i++) { auto lower = lower_bound(v.begin(), v.end(), a[i]); if (lower == v.end()) v.emplace_back(a[i]), b[i] = v.size(); else *lower = a[i], b[i] = lower - v.begin(); } for (int i = n; i >= 1; i--) { ll idx = lower_bound(u.begin(), u.end(), -a[i] + k) - u.begin(); ans = max(ans, b[i] + idx); auto lower = lower_bound(u.begin(), u.end(), -a[i]); if (lower == u.end()) u.emplace_back(-a[i]); else *lower = -a[i]; } printf("%lld", ans); }

컴파일 시 표준 에러 (stderr) 메시지

glo.cpp: In function 'int main()':
glo.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%lld %lld", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~
glo.cpp:12:39: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
      |                                  ~~~~~^~~~~~~~~~~~~~~
#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...