Submission #964331

#TimeUsernameProblemLanguageResultExecution timeMemory
964331AndreyGlobal Warming (CEOI18_glo)C++14
100 / 100
60 ms6516 KiB
#include <bits/stdc++.h> using namespace std; long long dude(vector<long long>& haha, long long x) { long long l = 0,r = haha.size()-1; while(l < r) { long long m = (l+r+1)/2; if(haha[m] < x) { l = m; } else { r = m-1; } } return l; } vector<int> br(200001); void calc(vector<int> haha) { reverse(haha.begin(),haha.end()); for(int i = 0; i < haha.size(); i++) { haha[i] = INT_MAX-haha[i]; } vector<long long> bruh(haha.size()+1,INT_MAX); bruh[0] = 0; for(int i = 0; i < haha.size(); i++) { int a = haha[i]; int c = dude(bruh,a); bruh[c+1] = a; br[haha.size()-i-1] = c+1; } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n,x,ans = 0; cin >> n >> x; vector<int> haha(n); for(int i = 0; i < n; i++) { cin >> haha[i]; } calc(haha); vector<long long> bruh(n+1,INT_MAX); bruh[0] = 0; for(int i = 0; i < n; i++) { int a = haha[i]; int c = dude(bruh,a+x); ans = max(ans,c+br[i]); c = dude(bruh,a); ans = max(ans,c+1); bruh[c+1] = a; } cout << ans; return 0; }

Compilation message (stderr)

glo.cpp: In function 'void calc(std::vector<int>)':
glo.cpp:22:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for(int i = 0; i < haha.size(); i++) {
      |                    ~~^~~~~~~~~~~~~
glo.cpp:27:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int i = 0; i < haha.size(); i++) {
      |                    ~~^~~~~~~~~~~~~
#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...