Submission #484422

#TimeUsernameProblemLanguageResultExecution timeMemory
484422XIIGlobal Warming (CEOI18_glo)C++17
0 / 100
40 ms2956 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define fi first #define se second #define mp make_pair #define eb emplace_back #define ALL(x) (x).begin(), (x).end() #define FOR(i, a, b) for(int i = (a); i < (b); ++i) #define FORU(i, a, b) for(int i = (a); i <= (b); ++i) #define FORD(i, a, b) for(int i = (a); i >= (b); --i) #define IOS cin.tie(0)->sync_with_stdio(false); #define PROB "CEOI18_glo" void Fi(){ if(fopen(PROB".inp", "r")){ freopen(PROB".inp", "r", stdin); freopen(PROB".out", "w", stdout); } } const int N = 2e5 + 1; int n, x, a[N]; int main(){ IOS; Fi(); cin >> n >> x; vector<int> d0{0}, d1{0}; FORU(i, 1, n){ cin >> a[i]; { int j = upper_bound(ALL(d0), a[i] + x) - d0.begin(); if(j == d1.size()) d1.eb(a[i]); else d1[j] = a[i]; } { int j = upper_bound(ALL(d0), a[i]) - d0.begin(); if(j == d0.size()) d0.eb(a[i]); else d0[j] = a[i]; } { int j = upper_bound(ALL(d1), a[i]) - d1.begin(); if(j == d1.size()) d1.eb(a[i]); else d1[j] = a[i]; } } cout << d1.size() - 1; return 0; }

Compilation message (stderr)

glo.cpp: In function 'int main()':
glo.cpp:37:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |             if(j == d1.size()) d1.eb(a[i]);
      |                ~~^~~~~~~~~~~~
glo.cpp:42:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |             if(j == d0.size()) d0.eb(a[i]);
      |                ~~^~~~~~~~~~~~
glo.cpp:47:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |             if(j == d1.size()) d1.eb(a[i]);
      |                ~~^~~~~~~~~~~~
glo.cpp: In function 'void Fi()':
glo.cpp:20:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         freopen(PROB".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
glo.cpp:21:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         freopen(PROB".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...