답안 #104900

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
104900 2019-04-09T14:24:25 Z daili 케이크 (CEOI14_cake) C++14
0 / 100
2000 ms 4600 KB
#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";
        }
    }


}

Compilation message

cake.cpp: In function 'int sim(std::vector<int>&, int, int)':
cake.cpp:27:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (currR < deli.size() - 1)
             ~~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 127 ms 640 KB Output isn't correct
2 Incorrect 110 ms 660 KB Output isn't correct
3 Incorrect 129 ms 640 KB Output isn't correct
4 Incorrect 113 ms 896 KB Output isn't correct
5 Incorrect 132 ms 640 KB Output isn't correct
6 Incorrect 134 ms 768 KB Output isn't correct
7 Incorrect 120 ms 768 KB Output isn't correct
8 Incorrect 111 ms 896 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2094 ms 2048 KB Time limit exceeded
2 Execution timed out 2004 ms 2176 KB Time limit exceeded
3 Incorrect 1889 ms 2172 KB Output isn't correct
4 Incorrect 2 ms 384 KB Output isn't correct
5 Execution timed out 2041 ms 3708 KB Time limit exceeded
6 Execution timed out 2070 ms 3684 KB Time limit exceeded
7 Execution timed out 2062 ms 3672 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Incorrect 77 ms 560 KB Output isn't correct
2 Incorrect 115 ms 668 KB Output isn't correct
3 Incorrect 1461 ms 1876 KB Output isn't correct
4 Incorrect 1471 ms 2152 KB Output isn't correct
5 Incorrect 156 ms 1272 KB Output isn't correct
6 Execution timed out 2050 ms 2160 KB Time limit exceeded
7 Incorrect 832 ms 2404 KB Output isn't correct
8 Incorrect 182 ms 2916 KB Output isn't correct
9 Execution timed out 2045 ms 4076 KB Time limit exceeded
10 Incorrect 622 ms 4600 KB Output isn't correct
11 Execution timed out 2048 ms 3264 KB Time limit exceeded
12 Execution timed out 2052 ms 3292 KB Time limit exceeded
13 Execution timed out 2037 ms 3952 KB Time limit exceeded