Submission #858494

#TimeUsernameProblemLanguageResultExecution timeMemory
858494hariaakas646Global Warming (CEOI18_glo)C++14
0 / 100
37 ms1884 KiB
#include <bits/stdc++.h> using namespace std; #define scd(t) scanf("%d", &t) #define sclld(t) scanf("%lld", &t) #define forr(i, j, k) for (int i = j; i < k; i++) #define frange(i, j) forr(i, 0, j) #define all(cont) cont.begin(), cont.end() #define mp make_pair #define pb push_back #define f first #define s second typedef long long int lli; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<bool> vb; typedef vector<lli> vll; typedef vector<string> vs; typedef vector<pii> vii; typedef vector<vi> vvi; typedef map<int, int> mpii; typedef set<int> seti; typedef multiset<int> mseti; typedef long double ld; void usaco() { freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin); // freopen("problem.out", "w", stdout); } int inf = 1e9 + 5; int main() { // usaco(); int n, x; scd(n); scd(x); vi vec(n); frange(i, n) scd(vec[i]); vi inc(n+1, inf); inc[0] = -inf; frange(i, n) { int it = upper_bound(all(inc), vec[i]) - inc.begin(); if(vec[i] > inc[it-1]) inc[it] = vec[i]; } vi dec; int ma = 0; for(int i=n-1; i>=0; i--) { if(inc[i] < inf) { int v = lower_bound(all(dec), -inc[i]-1) - dec.begin() + 1; ma = max(ma, i + v); } auto it = upper_bound(all(dec), -vec[i]) - dec.begin(); if(it == dec.size()) dec.pb(-vec[i]); if(it == 0 || -vec[i] > dec[it-1]) dec[it] = -vec[i]; } printf("%d", ma); }

Compilation message (stderr)

glo.cpp: In function 'int main()':
glo.cpp:63:15: warning: comparison of integer expressions of different signedness: 'long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |         if(it == dec.size()) dec.pb(-vec[i]);
      |            ~~~^~~~~~~~~~~~~
glo.cpp: In function 'void usaco()':
glo.cpp:30:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |     freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
glo.cpp: In function 'int main()':
glo.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
glo.cpp:41:5: note: in expansion of macro 'scd'
   41 |     scd(n);
      |     ^~~
glo.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
glo.cpp:42:5: note: in expansion of macro 'scd'
   42 |     scd(x);
      |     ^~~
glo.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
glo.cpp:44:18: note: in expansion of macro 'scd'
   44 |     frange(i, n) scd(vec[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...