# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
100105 | shafinalam | Global Warming (CEOI18_glo) | C++14 | 88 ms | 4736 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int mx = 2e5+5;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef pair<int,int>pii;
typedef pair<int,pii>piii;
#define sf scanf
#define pf printf
#define input freopen("input.txt","r",stdin)
#define output freopen("output.txt","w",stdout)
#define inf 1e16
#define ff first
#define ss second
#define MP make_pair
#define pb push_back
#define all(v) v.begin(), v.end()
#define printcase(cases) printf("Case %d:", cases);
#define Unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define FAST ios_base::sync_with_stdio(0);cout.tie(0)
#define endl printf("\n")
#define __lcm(a, b) ((a*b)/__gcd(a, b))
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
int suf[mx];
int arr[mx];
int n, x;
void LDS()
{
vector<int>v;
for(int i = 0; i < n; i++) v.push_back(0);
for(int i = n-1; i >= 0; i--)
{
int it = upper_bound(all(v), arr[i])-v.begin()-1;
v[it] = arr[i];
suf[i] = n-it;
}
}
void LIS()
{
int ans = 0;
vector<int>v;
for(int i = 0; i < n; i++)
{
int pos = lower_bound(all(v), arr[i]+x)-v.begin();
ans = max(ans, suf[i]+pos);
auto it = lower_bound(all(v), arr[i]);
if(it==v.end()) v.push_back(arr[i]);
else v[it-v.begin()] = arr[i];
}
pf("%d\n", ans);
}
int main()
{
sf("%d%d", &n, &x);
for(int i = 0; i < n; i++) sf("%d", &arr[i]);
LDS();
LIS();
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... |