Submission #371001

#TimeUsernameProblemLanguageResultExecution timeMemory
371001ntabc05101Global Warming (CEOI18_glo)C++14
100 / 100
71 ms5232 KiB
#ifndef LOCAL #define NDEBUG 1 #endif // LOCAL #include<bits/stdc++.h> #define taskname "" #define i64_ int64_t int main() { if (fopen(taskname".inp", "r")) { freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } else if (fopen(taskname".in", "r")) { freopen(taskname".in", "r", stdin); freopen(taskname".out", "w", stdout); } std::ios_base::sync_with_stdio(0); std::cin.tie(0); int n, x; std::cin>>n>>x; i64_ a[n]; for (int i=0; i<n; ++i) std::cin>>a[i]; int result=0; std::vector<int> lis; int dp[n]; for (int i=0; i<n; ++i) { int pos=std::lower_bound(begin(lis), end(lis), a[i])-begin(lis); if (pos==lis.size()) lis.emplace_back(a[i]); else lis[pos]=a[i]; dp[i]=1+pos; result=std::max(result, dp[i]); } lis.clear(); for (int i=n-1; i>=0; --i) { int pos=std::lower_bound(begin(lis), end(lis), -a[i])-begin(lis); int j=std::lower_bound(begin(lis), end(lis), -a[i]+x)-begin(lis); if (pos==lis.size()) lis.emplace_back(-a[i]); else lis[pos]=-a[i]; result=std::max(result, dp[i]+j); } std::cout<<result<<"\n"; return 0; }

Compilation message (stderr)

glo.cpp: In function 'int main()':
glo.cpp:31:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |                 if (pos==lis.size()) lis.emplace_back(a[i]);
      |                     ~~~^~~~~~~~~~~~
glo.cpp:43:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |                 if (pos==lis.size()) lis.emplace_back(-a[i]);
      |                     ~~~^~~~~~~~~~~~
glo.cpp:11:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   11 |                 freopen(taskname".inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
glo.cpp:12:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   12 |                 freopen(taskname".out", "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
glo.cpp:15:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   15 |                 freopen(taskname".in", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
glo.cpp:16:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   16 |                 freopen(taskname".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...