제출 #853038

#제출 시각아이디문제언어결과실행 시간메모리
853038lovrotGlobal Warming (CEOI18_glo)C++17
100 / 100
61 ms4020 KiB
#include <cstdio> 
#include <algorithm>

using namespace std;

const int N = 2e5 + 10;
const int oo = 2e9 + 10;

int n, x, A[N]; 

int LIS[N], L[N];

int main() {
	scanf("%d%d", &n, &x); 
	for(int i = 0; i < n; ++i) LIS[i] = oo;
	for(int i = 0; i < n; ++i) {
		scanf("%d", A + i); 
		int j = lower_bound(LIS, LIS + n, A[i]) - LIS;
		LIS[j] = A[i]; 
		L[i] = j;
	}
	for(int i = 0; i < n; ++i) LIS[i] = -oo;
	int ans = 0;
	for(int i = n - 1; i >= 0; --i) {
		ans = max(ans, (int) (lower_bound(LIS, LIS + n, A[i] - x, [](int a, int b) {
			return a > b;
		}) - LIS) + L[i] + 1);
		int j = lower_bound(LIS, LIS + n, A[i], [](int a, int b) { return a > b; }) - LIS; 
		LIS[j] = A[i];
	}
	printf("%d\n", ans);
	return 0;
}

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

glo.cpp: In function 'int main()':
glo.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  scanf("%d%d", &n, &x);
      |  ~~~~~^~~~~~~~~~~~~~~~
glo.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |   scanf("%d", 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...