제출 #1067685

#제출 시각아이디문제언어결과실행 시간메모리
1067685CodeLakVNGlobal Warming (CEOI18_glo)C++17
100 / 100
40 ms5468 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define name "LIS" #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define FOD(i, b, a) for (int i = (b); i >= (a); i--) template <class U, class V> bool maximize(U &x, V y) { if (x < y) { x = y; return true; } return false; } template <class U, class V> bool minimize(U &x, V y) { if (x > y) { x = y; return true; } return false; } const int INF = 2e9 + 7; const int N = 3e5 + 5; int a[N]; int main() { ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0); if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); } int n, d; cin >> n >> d; FOR(i, 1, n) cin >> a[i]; vector<int> f(n + 1, 0); f[0] = INF; vector<int> suff(n + 1, 0); int ans = 0; FOD(i, n, 1) { int idx = lower_bound(f.begin(), f.end(), a[i], greater<int>()) - f.begin(); suff[i] = idx; f[idx] = a[i]; maximize(ans, idx); } f = vector<int>(n + 1, INF); f[0] = 0; FOR(i, 1, n - 1) { int idx = lower_bound(f.begin(), f.end(), a[i]) - f.begin(); f[idx] = a[i]; idx = lower_bound(f.begin(), f.end(), a[i + 1] + d) - f.begin(); maximize(ans, idx + suff[i + 1] - 1); } cout << ans; return 0; }

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

glo.cpp: In function 'int main()':
glo.cpp:32:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |         freopen(name".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
glo.cpp:33:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...