Submission #397041

#TimeUsernameProblemLanguageResultExecution timeMemory
397041jsannemoGlobal Warming (CEOI18_glo)C++14
10 / 100
63 ms3192 KiB
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; int main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); int N, D; cin >> N >> D; typedef pair<int, int> p; vector<p> res1, res2; rep(i,0,N) { int x; cin >> x; auto it1 = lower_bound(all(res1), p{x, 0}); if (it1 == res1.end()) res1.emplace_back(), it1 = res1.end()-1; *it1 = {x, i}; auto it2 = lower_bound(all(res2), p{x, 0}); if (it2 == res2.end()) res2.emplace_back(), it2 = res2.end()-1; *it2 = {x, i}; int it3 = lower_bound(all(res1), p{x+D, 0}) - res1.begin(); if (it3 == sz(res2)) res2.emplace_back(x, i); res2[it3] = {x, i}; } cout << max(sz(res1), sz(res2)) << endl; }
#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...