Submission #441653

#TimeUsernameProblemLanguageResultExecution timeMemory
441653linkretGlobal Warming (CEOI18_glo)C++14
0 / 100
337 ms31680 KiB
#include <bits/stdc++.h> using namespace std; int h [300000]; int fen [500002]; vector <int> pom; map <int, int> comp; int dp1 [300000]; int dp2 [300000]; const int MAXN = 500000+1; //fenwick int query (int x){ int sol=0; for (x; x>0; x-= (x & -x)) sol=max (sol, fen[x]); return sol; } void add (int x, int val){ for (x; x<500002; x+= (x & -x)) fen [x]=max (fen[x], val); } int main(){ //input int n, x; cin >> n >> x; for (int i=0; i<n; i++) cin >> h[i]; //compression for (int i=0; i<n; i++) pom.push_back(h[i]); for (int i=0; i<n; i++) pom.push_back(h[i]+x); sort (pom.begin(), pom.end()); for (int i=0; i<pom.size(); i++) comp [pom[i]]=i+1; //precompute right dynamic for (int i=n-1; i>=0; i--){ int hi=comp[h[i]]; int height=MAXN-hi; dp2 [i]=query (height)+1; add (height+1, dp2[i]); } //for (int i=0; i<n; i++) cout << dp2[i] << " "; memset (fen, 0, sizeof (fen)); //computing result int sol=0; for (int i=0; i<n; i++){ int hi=comp[h[i]+x]; int res=query (hi)+dp2[i]; dp1 [i]=query (h[i])+1; add (h[i], dp1[i]); sol=max (sol, res); } cout << sol << endl; return 0; }

Compilation message (stderr)

glo.cpp: In function 'int query(int)':
glo.cpp:7:7: warning: statement has no effect [-Wunused-value]
    7 |  for (x; x>0; x-= (x & -x)) sol=max (sol, fen[x]);
      |       ^
glo.cpp: In function 'void add(int, int)':
glo.cpp:11:7: warning: statement has no effect [-Wunused-value]
   11 |  for (x; x<500002; x+= (x & -x)) fen [x]=max (fen[x], val);
      |       ^
glo.cpp: In function 'int main()':
glo.cpp:22:17: 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<pom.size(); i++) comp [pom[i]]=i+1;
      |                ~^~~~~~~~~~~
#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...