Submission #104901

# Submission time Handle Problem Language Result Execution time Memory
104901 2019-04-09T14:34:05 Z daili Cake (CEOI14_cake) C++14
0 / 100
2000 ms 7136 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;
    map<int,int> top10m;

    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());
    vector<int> top10;
    for (int i = copy1.size() - 1; i >= 0 && i >= n-10; i--)
    {
        top10m[copy1[i].second] = i;
        top10.push_back(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]]++;
            }

            if (!top10m.count(id))
            {
              top10m.erase(top10m.find(top10.back()));
              top10m[id] = e;
              for (int i = top10.size()-1; i > e; i--)
              {
                  top10[i] = top10[i-1];
              }
            }
            else
            {
              for (int i = top10m[id]; i > e; i--)
              {
                  top10[i] = top10[i-1];
              }
            }

            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)
             ~~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 1280 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 7 ms 1152 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 9 ms 1152 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Execution timed out 2054 ms 640 KB Time limit exceeded
5 Runtime error 11 ms 1532 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 7 ms 1404 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 10 ms 1532 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Execution timed out 2037 ms 896 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 2037 ms 2184 KB Time limit exceeded
2 Runtime error 266 ms 3300 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 61 ms 3316 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Correct 2 ms 384 KB Output is correct
5 Execution timed out 2037 ms 3720 KB Time limit exceeded
6 Execution timed out 2055 ms 3828 KB Time limit exceeded
7 Runtime error 59 ms 6880 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 816 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 9 ms 896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 1174 ms 2660 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 20 ms 2168 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 6 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 249 ms 2816 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 19 ms 1152 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 24 ms 3560 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Execution timed out 2024 ms 3932 KB Time limit exceeded
10 Runtime error 7 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 81 ms 1652 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Execution timed out 2041 ms 3256 KB Time limit exceeded
13 Runtime error 68 ms 7136 KB Execution killed with signal 11 (could be triggered by violating memory limits)