답안 #1108947

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1108947 2024-11-05T17:27:11 Z csibe_csavo Global Warming (CEOI18_glo) C++14
17 / 100
47 ms 5584 KB
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,d; cin>>n>>d;
	vector<int> v(n+2);
	for(int i=1; i<=n; i++)
		cin>>v[i];
	vector<int> lis,dpel(n+1);
	for(int i=1; i<=n; i++)
	{
		int ind=lower_bound(lis.begin(),lis.end(),v[i])-lis.begin();
		if(ind>=lis.size()) lis.push_back(v[i]);
		else lis[ind]=v[i];
		dpel[i]=lis.size();
	}
	vector<int> dphat(n+2),r(n+2);
	lis.clear();
	for(int i=n; i>0; i--)
	{	
		int ujert=v[i]-d;
		ujert=-ujert;
		int ind=lower_bound(lis.begin(),lis.end(),ujert)-lis.begin();
		r[i]=ind+1;
		v[i]=-v[i];
		ind=lower_bound(lis.begin(),lis.end(),v[i])-lis.begin();
		if(ind<lis.size()) lis[ind]=v[i];
		else lis.push_back(v[i]);
	}
	int ans=1;
	for(int i=1; i<=n; i++)
		ans=max(ans,dpel[i]+r[i]-1);
	cout<<ans<<"\n";
	
}

Compilation message

glo.cpp: In function 'int main()':
glo.cpp:15:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |   if(ind>=lis.size()) lis.push_back(v[i]);
      |      ~~~^~~~~~~~~~~~
glo.cpp:29:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |   if(ind<lis.size()) lis[ind]=v[i];
      |      ~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Incorrect 1 ms 508 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Incorrect 1 ms 508 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Incorrect 1 ms 508 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 47 ms 3400 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 1104 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 1884 KB Output is correct
2 Correct 22 ms 1872 KB Output is correct
3 Correct 36 ms 3548 KB Output is correct
4 Correct 24 ms 5072 KB Output is correct
5 Correct 11 ms 2772 KB Output is correct
6 Correct 20 ms 3748 KB Output is correct
7 Correct 24 ms 5584 KB Output is correct
8 Correct 18 ms 3012 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Incorrect 1 ms 508 KB Output isn't correct
4 Halted 0 ms 0 KB -