# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
405670 | souvenir_vayne | Knjige (COCI20_knjige) | C++14 | 32 ms | 584 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
int32_t main() {
int n;
cin >> n;
long long ans = 0;
for(int i = 0; i < n; i++)
ans += 2 * (n - i) + 2*(n - i - 1);
cout << ans << endl;
stack<int> left, right;
for(int i = 0; i < n; i++) {
int x;
cin >> x;
left.push(x);
}
stack<int> aux;
while(!left.empty()) {
aux.push(left.top());
left.pop();
}
left = aux;
int did = 0;
while(did < n) {
int mn = INT_MAX;
aux = left;
while(!aux.empty()) {
mn = min(mn, aux.top());
aux.pop();
}
bool taken = false;
for(int i = 0; i < n - did; i++) {
if(left.top() == mn && !taken) {
taken = true;
cout << "UZMI L L" << endl;
}
else {
cout << "UZMI D L" << endl << "STAVI D D" << endl;
right.push(left.top());
}
left.pop();
}
did++;
cout << "STAVI L L" << endl;
while(!right.empty()) {
cout << "UZMI D D" << endl << "STAVI D L" << endl;
left.push(right.top());
right.pop();
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |