Submission #763049

#TimeUsernameProblemLanguageResultExecution timeMemory
763049KN200711Global Warming (CEOI18_glo)C++14
10 / 100
48 ms2396 KiB
# include <bits/stdc++.h>
using namespace std;

int main() {
	int N, x;
	scanf("%d %d", &N, &x);
	
	vector<int> wt, wi;
	wt.clear();
	wi.clear();
	for(int i=0;i<N;i++) {
		int A;
		scanf("%d", &A);
		
		int A1 = A + x;
		int P = lower_bound(wi.begin(), wi.end(), A1) - wi.begin();
		if(P == wi.size()) wi.push_back(A1);
		else wi[P] = A1;
		
		P = lower_bound(wt.begin(), wt.end(), A1) - wt.begin();
		if(P == wi.size()) wi.push_back(A1);
		else if(wi[P] >= A1) wi[P] = A1;
		
		P = lower_bound(wt.begin(), wt.end(), A) - wt.begin(); 
		if(P == wt.size()) wt.push_back(A);
		else wt[P] = A;
	}
	printf("%d\n", max(wt.size(), wi.size()));
}

Compilation message (stderr)

glo.cpp: In function 'int main()':
glo.cpp:17:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |   if(P == wi.size()) wi.push_back(A1);
      |      ~~^~~~~~~~~~~~
glo.cpp:21:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |   if(P == wi.size()) wi.push_back(A1);
      |      ~~^~~~~~~~~~~~
glo.cpp:25:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |   if(P == wt.size()) wt.push_back(A);
      |      ~~^~~~~~~~~~~~
glo.cpp:28:11: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
   28 |  printf("%d\n", max(wt.size(), wi.size()));
      |          ~^     ~~~~~~~~~~~~~~~~~~~~~~~~~
      |           |        |
      |           int      long unsigned int
      |          %ld
glo.cpp:6:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |  scanf("%d %d", &N, &x);
      |  ~~~~~^~~~~~~~~~~~~~~~~
glo.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |   scanf("%d", &A);
      |   ~~~~~^~~~~~~~~~
#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...