제출 #874627

#제출 시각아이디문제언어결과실행 시간메모리
874627sleepntsheep등산 경로 (IZhO12_route)C++17
0 / 100
1 ms512 KiB
#include <iostream> #include <cassert> #include <cstring> #include <vector> #include <algorithm> #include <deque> #include <set> #include <utility> #include <array> using i64 = long long; using u64 = unsigned long long; using f64 = double; using f80 = long double; using namespace std; #define ALL(x) x.begin(), x.end() #define ShinLena cin.tie(nullptr)->sync_with_stdio(false); #define N 1000000 int z, n, k; i64 a[N+3]; int main() { ShinLena; cin >> n >> k; a[0] = a[n+2] = 1e18+1; for (int i = 1; i <= n; ++i) cin >> a[i]; a[n+1] = a[0]; n += 3; deque<i64> v; deque<int> s = {0}; for (int i = 1; i < n; ++i) { for (; s.size() && a[s.back()] <= a[i]; ) { if (a[s.back()] == 1e18+1 && a[i] == 1e18+1) break; v.push_back(i - s.back() - 1); cout << s.back() << ' ' << i << endl; s.pop_back(); } s.push_back(i); } sort(ALL(v)); for (; v.size() && v[0] == 0; ) v.pop_front(); for (; v.size() && k >= v[0]; ) z += 2, k -= v[0], v.pop_front(); cout << z; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...