# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
872482 |
2023-11-13T07:49:19 Z |
aeg |
Knjige (COCI20_knjige) |
C++17 |
|
1 ms |
752 KB |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
deque<int> l(n);
stack<int> r;
for(int i=0; i<n; i++) cin >> l[i];
while(!l.empty() && *max_element(l.begin(), l.end()) == l.back()) {
l.pop_back();
}
int cnt = 0;
string ans;
while(!l.empty()){
int cur = *max_element(l.begin(), l.end());
if(cur == l.back()) {
l.pop_back();
continue;
}
while(l.front()!=cur) {
ans += "UZMI L L\n";
ans += "STAVI L D\n";
cnt += 2;
r.push(l.front());
l.pop_front();
}
ans += "UZMI D L\n";
cnt ++;
l.pop_front();
while(!l.empty()) {
ans += "UZMI L L\n";
ans += "STAVI L D\n";
cnt += 2;
r.push(l.front());
l.pop_front();
}
ans += "STAVI D L\n";
cnt ++;
while(!r.empty()) {
ans += "UZMI L D\n";
ans += "STAVI L L\n";
cnt += 2;
l.push_front(r.top());
r.pop();
}
}
cout << cnt << endl << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
752 KB |
Output is correct |
2 |
Correct |
1 ms |
748 KB |
Output is correct |
3 |
Correct |
1 ms |
752 KB |
Output is correct |
4 |
Correct |
1 ms |
752 KB |
Output is correct |
5 |
Correct |
1 ms |
748 KB |
Output is correct |
6 |
Correct |
1 ms |
748 KB |
Output is correct |
7 |
Correct |
1 ms |
748 KB |
Output is correct |
8 |
Correct |
1 ms |
752 KB |
Output is correct |
9 |
Correct |
1 ms |
752 KB |
Output is correct |
10 |
Correct |
1 ms |
752 KB |
Output is correct |