# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
104900 | daili | 케이크 (CEOI14_cake) | C++14 | 2094 ms | 4600 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int sim(vector<int>& deli , int a, int b)
{
int eaten = 1;
a--; b--;
if (a == b)
{
return 0;
}
int currL = a;
int currR = a;
while(true)
{
int L = 99999999;
if (currL > 0)
{
L = deli[currL - 1];
}
int R = 99999999;
if (currR < deli.size() - 1)
{
R = deli[currR + 1];
}
if (L < R)
{
if (currL - 1 == b)
{
return eaten;
}
currL--;
}
else
{
if (currR + 1 == b)
{
return eaten;
}
currR++;
}
eaten++;
}
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, a;
cin >> n >> a;
vector<pair<int,int>> copy1;
vector<int> deli;
for (int i = 0; i < n; i++)
{
int x;
cin >> x;
deli.push_back(x);
copy1.push_back({x, i});
}
sort(copy1.begin(), copy1.end());
set<int> top10s;
vector<int> top10;
for (int i = copy1.size() - 1; i >= 0 && i >= n-10; i--)
{
top10.push_back(copy1[i].second);
top10s.insert(copy1[i].second);
}
int q;
cin >> q;
while(q--)
{
char type;
cin >> type;
if (type == 'E')
{
int id, e;
cin >> id >> e;
e--; id--;
for (int i = 0; i < e; i++)
{
deli[top10[i]]++;
}
int cnt = 1;
for (int i = top10.size()-1; i > e+1; i--)
{
if (top10[i-1] == id) cnt++;
top10[i] = top10[i-cnt];
}
top10[e] = id;
deli[id] = deli[top10[e+1]] + 1;
}
else
{
int b;
cin >> b;
int res = sim(deli, a, b);
cout << res << "\n";
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |