Submission #484432

#TimeUsernameProblemLanguageResultExecution timeMemory
484432XIIGlobal Warming (CEOI18_glo)C++17
100 / 100
40 ms3960 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, d1; FORU(i, 1, n){ cin >> a[i]; { int j = lower_bound(ALL(d1), a[i]) - d1.begin(); if(j == d1.size()) d1.eb(a[i]); else d1[j] = min(d1[j], a[i]); } { int j = lower_bound(ALL(d0), a[i]) - d0.begin(); if(j == d0.size()) d0.eb(a[i]); else d0[j] = a[i]; if(j == d1.size()) d1.eb(a[i] - x); else d1[j] = min(d1[j], a[i] - x); // for(int x: d1) cout << x << " "; // cout << "d1\n"; // for(int x: d0) cout << x << " "; // cout << "\n"; } } cout << d1.size(); 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:44:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |             if(j == d1.size()) d1.eb(a[i] - x);
      |                ~~^~~~~~~~~~~~
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...