Submission #731792

#TimeUsernameProblemLanguageResultExecution timeMemory
731792beabossGlobal Warming (CEOI18_glo)C++14
17 / 100
105 ms4192 KiB
#include "bits/stdc++.h" using namespace std; #define s second #define f first #define pb push_back typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pii; // const int INF = 1e17; const int N = 2*1e5 + 10; int main() { int n, x; cin >> n >> x; vi vals(n); vi dp(n); vi cur; for (int i = 0; i < n; i++) { cin >> vals[i]; auto ind = lower_bound(cur.begin(), cur.end(), vals[i]) - cur.begin(); if (ind == cur.size()) cur.pb(vals[i]); else cur[ind] = vals[i]; dp[i] = cur.size(); } cur.erase(cur.begin(), cur.end()); int ans = 0; for (int i = n-1; i >= 0; i--) { int possible = lower_bound(cur.begin(), cur.end(), -vals[i] + x) - cur.begin(); // cout << i << possible << endl; ans = max(ans, dp[i] + possible); int ind = lower_bound(cur.begin(), cur.end(), -vals[i]) - cur.begin(); if (ind == cur.size()) cur.pb(-vals[i]); else cur[ind]=-vals[i]; } assert(dp[n-1] == cur.size()); cout << ans << endl; }

Compilation message (stderr)

glo.cpp: In function 'int main()':
glo.cpp:30:11: warning: comparison of integer expressions of different signedness: 'long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |   if (ind == cur.size()) cur.pb(vals[i]);
      |       ~~~~^~~~~~~~~~~~~
glo.cpp:43:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |   if (ind == cur.size()) cur.pb(-vals[i]);
      |       ~~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from glo.cpp:1:
glo.cpp:48:17: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |  assert(dp[n-1] == cur.size());
#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...