Submission #50263

# Submission time Handle Problem Language Result Execution time Memory
50263 2018-06-08T17:33:11 Z gs13105 Semiexpress (JOI17_semiexpress) C++17
100 / 100
18 ms 3536 KB
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <iterator>

using namespace std;

int arr[3010];
vector<int> mem[3010];

struct str
{
    int x, y;
    bool operator <(const str &a) const
    {
        return mem[x][y] < mem[a.x][a.y];
    }
};

int main()
{
    //freopen("in", "r", stdin);
    //freopen("out", "w", stdout);

    int n, m, k, a, b, c, i, j;
    long long t;
    scanf("%d%d%d%d%d%d%lld", &n, &m, &k, &a, &b, &c, &t);
    for(i = 0; i < m; i++)
        scanf("%d", &arr[i]);

    k -= m;

    priority_queue<str> pq;
    int r = -1;
    for(i = 0; i < m - 1; i++)
    {
        long long t2 = t - 1LL * b * (arr[i] - 1);
        int sum = 0;
        for(j = 0; t2 >= 0 && j <= k; j++)
        {
            long long x = 1 + t2 / a;
            if(x + sum >= arr[i + 1] - arr[i])
            {
                mem[i].push_back(arr[i + 1] - arr[i] - sum);
                break;
            }

            mem[i].push_back(x);
            sum += x;
            t2 -= 1LL * c * x;
        }

        if(mem[i].size() >= 1)
        {
            r += mem[i][0];
            if(mem[i].size() >= 2)
                pq.push({ i, 1 });
        }
    }
    if(1LL * b * (n - 1) <= t)
        r++;

    for(i = 0; !pq.empty() && i < k; i++)
    {
        str p = pq.top();
        pq.pop();

        r += mem[p.x][p.y];
        if(p.y + 1 < mem[p.x].size())
            pq.push({ p.x, p.y + 1 });
    }

    printf("%d\n", r);
    return 0;
}

Compilation message

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:81:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(p.y + 1 < mem[p.x].size())
            ~~~~~~~~^~~~~~~~~~~~~~~~~
semiexpress.cpp:39:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d%d%d%d%lld", &n, &m, &k, &a, &b, &c, &t);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:41:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &arr[i]);
         ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 544 KB Output is correct
4 Correct 2 ms 544 KB Output is correct
5 Correct 2 ms 544 KB Output is correct
6 Correct 2 ms 724 KB Output is correct
7 Correct 2 ms 724 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 544 KB Output is correct
4 Correct 2 ms 544 KB Output is correct
5 Correct 2 ms 544 KB Output is correct
6 Correct 2 ms 724 KB Output is correct
7 Correct 2 ms 724 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 2 ms 724 KB Output is correct
10 Correct 2 ms 788 KB Output is correct
11 Correct 2 ms 788 KB Output is correct
12 Correct 2 ms 788 KB Output is correct
13 Correct 2 ms 788 KB Output is correct
14 Correct 2 ms 788 KB Output is correct
15 Correct 2 ms 788 KB Output is correct
16 Correct 2 ms 788 KB Output is correct
17 Correct 2 ms 788 KB Output is correct
18 Correct 3 ms 788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 544 KB Output is correct
4 Correct 2 ms 544 KB Output is correct
5 Correct 2 ms 544 KB Output is correct
6 Correct 2 ms 724 KB Output is correct
7 Correct 2 ms 724 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 2 ms 724 KB Output is correct
10 Correct 2 ms 788 KB Output is correct
11 Correct 2 ms 788 KB Output is correct
12 Correct 2 ms 788 KB Output is correct
13 Correct 2 ms 788 KB Output is correct
14 Correct 2 ms 788 KB Output is correct
15 Correct 2 ms 788 KB Output is correct
16 Correct 2 ms 788 KB Output is correct
17 Correct 2 ms 788 KB Output is correct
18 Correct 3 ms 788 KB Output is correct
19 Correct 3 ms 788 KB Output is correct
20 Correct 3 ms 996 KB Output is correct
21 Correct 2 ms 996 KB Output is correct
22 Correct 3 ms 1032 KB Output is correct
23 Correct 18 ms 3536 KB Output is correct
24 Correct 3 ms 3536 KB Output is correct
25 Correct 2 ms 3536 KB Output is correct
26 Correct 3 ms 3536 KB Output is correct
27 Correct 2 ms 3536 KB Output is correct
28 Correct 3 ms 3536 KB Output is correct
29 Correct 10 ms 3536 KB Output is correct
30 Correct 7 ms 3536 KB Output is correct