| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1094986 | TVSown | Global Warming (CEOI18_glo) | C++17 | 46 ms | 6112 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
///*** Sown_Vipro ***///
/// ->GIAI BA QUOC GIA<- ///
#include<bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("popcnt")
#define F first
#define S second
#define pb push_back
#define pi pair<int, int>
#define pii pair<int, pair<int, int> >
#define inp(name) if(fopen(name, "r")) freopen(name, "r", stdin);
#define out(name) if(fopen(name, "w")) freopen(name, "w", stdout);
#define szz(s) int(s.size())
const int N = 1e6 + 5, MAX = 1e6, oo = 1e9 + 5, MOD = 1e9 + 7;
int n, x, res;
int a[N], m[N];
vector<int> L;
void solve(){
cin >> n >> x;
for(int i = 1; i <= n; ++i) cin >> a[i];
L.pb(a[1]); m[1] = 1;
for(int i = 2; i <= n; ++i){
if(a[i] > L.back()){
L.pb(a[i]);
m[i] = L.size();
}else{
int id = lower_bound(L.begin(), L.end(), a[i]) - L.begin();
L[id] = a[i];
m[i] = id + 1;
}
// cout << m[i] << " ";
}
res = L.size();
L.clear(); L.pb(a[n]);
for(int i = n - 1; i >= 1; --i){
int l = 0, r = L.size() - 1;
while(l <= r){
int mid = (l + r) / 2;
if(L[mid] > a[i] - x){
l = mid + 1;
}else r = mid - 1;
}
res = max(res, m[i] + r + 1);
if(a[i] < L.back()){
L.pb(a[i]);
}else{
int l = 0, r = L.size() - 1;
while(l <= r){
int mid = (l + r) / 2;
if(L[mid] <= a[i]){
r = mid - 1;
}else l = mid + 1;
}
L[l] = a[i];
}
// for(int x : L) cout << x << " ";
// cout << "\n";
}
cout << res;
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
inp("in.txt");
int t = 1;
// cin >> t;
while(t--){
solve();
}
}
컴파일 시 표준 에러 (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... | ||||
