| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 310941 | Falcon | Global Warming (CEOI18_glo) | C++17 | 131 ms | 9432 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
#ifdef DEBUG
#include "debug.hpp"
#endif
using namespace std;
#define all(c)              (c).begin(), (c).end()
#define rall(c)             (c).rbegin(), (c).rend()
#define traverse(c, it)     for(auto it = (c).begin(); it != (c).end(); ++it)
#define rep(i, N)           for(int i = 0; i < (N); ++i)
#define rep1(i, N)          for(int i = 1; i <= (N); ++i)
#define rep2(i, s, e)       for(int i = (s); i <= (e); ++i)
#define rep3(i, s, e, d)    for(int i = (s); (d) >= 0 ? i <= (e) : i >= (e); i += (d))
#define pb push_back
#ifdef DEBUG
#define debug(x...)         { dbg::depth++; string dbg_vals = dbg::to_string(x); dbg::depth--; dbg::fprint(__func__, __LINE__, #x, dbg_vals); }
#define light_debug(x)      { dbg::light = 1; dbg::dout << __func__ << ":" << __LINE__ << "  " << #x << " = " << x << endl; dbg::light = 0; }
#else
#define debug(x...)         42
#define light_debug(x)      42
#endif
template<typename T>
inline T& ckmin(T& a, T b) { return a = a > b ? b : a; }
template<typename T>
inline T& ckmax(T& a, T b) { return a = a < b ? b : a; }
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
template<typename IT, typename T>
vi lis_ending_at(IT s, IT e, const T& comp) {
	int n{e - s};
	vi v, dp(n);
	rep(i, n) {
		int x = *(s + i);
		auto it = lower_bound(all(v), x, comp);
		dp[i] = it - v.begin() + 1;
		if(it == v.end()) v.pb(x);
		else *it = x;
	}
	return dp;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
#ifdef DEBUG
	freopen("debug", "w", stderr);
#endif
	int n, x; cin >> n >> x;
	vi a(n); rep(i, n) cin >> a[i];
	vi end_at{lis_ending_at(all(a), less<int>())};
	vi start_at{lis_ending_at(rall(a), greater<int>())}; reverse(all(start_at));
	debug(start_at, end_at);
	map<int, int> mp; mp[INT_MAX] = 0;
	vi tmp;
	int ans{0};
	rep3(i, n - 1, 0, -1) {
		auto it = mp.upper_bound(a[i]);
		ckmax(ans, end_at[i] + it->second);
		
		it = mp.upper_bound(a[i] + x);
		if(it != mp.end() && it->second >= start_at[i]) 
			continue;
		
		while(it != mp.begin()) { 
			--it;
			if(it->second <= start_at[i]) tmp.pb(it->first);
			else break;
		}
		for(auto v : tmp) mp.erase(v);
		tmp.clear();
		mp[a[i] + x] = start_at[i];
	}
	cout << ans << '\n';
	
#ifdef DEBUG
	dbg::dout << "\nExecution time: " << clock() << "ms\n";
#endif
	return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
