Submission #476510

#TimeUsernameProblemLanguageResultExecution timeMemory
476510RambaXGorillaGlobal Warming (CEOI18_glo)C++17
100 / 100
86 ms5360 KiB
#include<cstdio> #include<climits> #include<algorithm> using namespace std; int N, X; int temps[200010]; int incSubs[200010]; int decSubs[200010]; int lengths[200010]; int main(){ scanf("%d%d",&N,&X); for(int i = 0;i < N;i++){ scanf("%d",&temps[i]); } fill(incSubs, incSubs + N, INT_MAX); for(int i = 0;i < N;i++){ int pos = lower_bound(incSubs, incSubs + N, temps[i]) - incSubs; incSubs[pos] = temps[i]; lengths[i] = pos + 1; } int longest = 0; fill(decSubs, decSubs + N, INT_MAX); for(int i = N - 1;i > -1;i--){ int pos1 = lower_bound(decSubs, decSubs + N, X - temps[i]) - decSubs; longest = max(longest, lengths[i] + pos1); int pos2 = lower_bound(decSubs, decSubs + N, -temps[i]) - decSubs; decSubs[pos2] = -temps[i]; } printf("%d",longest); }

Compilation message (stderr)

glo.cpp: In function 'int main()':
glo.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%d%d",&N,&X);
      |     ~~~~~^~~~~~~~~~~~~~
glo.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf("%d",&temps[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...