답안 #34103

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
34103 2017-11-07T10:51:04 Z nickyrio Semiexpress (JOI17_semiexpress) C++14
100 / 100
0 ms 2540 KB
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i<=b ; i++)
#define FORD(i, a, b) for (int i = a; i>=b; i--)
#define REP(i, a) for (int i = 0; i<a; i++)
#define N 100100
#define pp pair<int, int>
#define IO cin.tie(NULL);cout.tie(NULL);
template<typename T> inline void read(T &x) {
    char c;
    bool neg = false;
    while (!isdigit(c = getchar()) && c != '-');
    x = 0;
    if (c == '-') {
        neg = true;
        c = getchar();
    }
    do {
        x = x * 10 + c - '0';
    } while (isdigit(c = getchar()));
    if (neg) x = -x;
}
template<typename T> inline void write(T x) {
    if (x < 0) {
        putchar('-');
        write(-x);
        return;
    }
    if (x < 10) {
        putchar(char(x + 48));
    }
    else {
        write(x/10);
        putchar(char(48 + x%10));
    }
}
template<typename T> inline void writeln(T x) {
    write(x);
    putchar('\n');
}
using namespace std;

int n, m, k, s[N];
long long t, b, a, c;
priority_queue<int> heap;
multiset<int> tab;
int main() {
    IO;
    read(n);read(m);read(k);
    read(a);read(b);read(c);
    read(t);
    FOR(i, 1, m) read(s[i]);
    int ans = 0, used = 0;
    k -= m;
    FOR(i, 1, m - 1) {
        long long newT = t - (s[i] - 1) * b;
        if (newT < 0) break;
        int now = s[i];
        if ((newT - c * (now - s[i])) / a >= s[i + 1] - s[i] - 1) {
            ans += s[i + 1] - s[i];
            continue;
        }
        int cnt = 0;
        while (true) {
            if (cnt == k) break;
            if (newT - c * (now - s[i]) < 0) break;
            if (now + (newT - c * (now - s[i])) / a >= s[i + 1]) {
                //heap.push(s[i + 1] - now);
                if (tab.size() < k) tab.insert(s[i + 1] - now);
                else {
                    if (s[i + 1] - now > *tab.begin()) {
                        tab.erase(tab.begin());
                        tab.insert(s[i + 1] - now);
                    }
                }
                break;
            }
            if (now != s[i]) {
                cnt++;
                //heap.push((newT - c * (now - s[i])) / a + 1);
                if (tab.size() < k) tab.insert((newT - c * (now - s[i])) / a + 1);
                else {
                    if ((newT - c * (now - s[i])) / a + 1 > *tab.begin()) {
                        tab.erase(tab.begin());
                        tab.insert((newT - c * (now - s[i])) / a + 1);
                    } else break;
                }
            } else ans += (newT - c * (now - s[i])) / a + 1;
            now = now + (newT - c * (now - s[i])) / a + 1;
        }
    }
    if (b * (n - 1) <= t) ans++;
    auto it = tab.end();
    while (used < k && it != tab.begin()) {
        it--;
        ans += *it;
        used++;
    }
    writeln(ans - 1);
}

Compilation message

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:68:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if (tab.size() < k) tab.insert(s[i + 1] - now);
                                ^
semiexpress.cpp:80:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if (tab.size() < k) tab.insert((newT - c * (now - s[i])) / a + 1);
                                ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2408 KB Output is correct
2 Correct 0 ms 2408 KB Output is correct
3 Correct 0 ms 2408 KB Output is correct
4 Correct 0 ms 2408 KB Output is correct
5 Correct 0 ms 2408 KB Output is correct
6 Correct 0 ms 2408 KB Output is correct
7 Correct 0 ms 2408 KB Output is correct
8 Correct 0 ms 2408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2408 KB Output is correct
2 Correct 0 ms 2408 KB Output is correct
3 Correct 0 ms 2408 KB Output is correct
4 Correct 0 ms 2408 KB Output is correct
5 Correct 0 ms 2408 KB Output is correct
6 Correct 0 ms 2408 KB Output is correct
7 Correct 0 ms 2408 KB Output is correct
8 Correct 0 ms 2408 KB Output is correct
9 Correct 0 ms 2408 KB Output is correct
10 Correct 0 ms 2408 KB Output is correct
11 Correct 0 ms 2408 KB Output is correct
12 Correct 0 ms 2408 KB Output is correct
13 Correct 0 ms 2408 KB Output is correct
14 Correct 0 ms 2408 KB Output is correct
15 Correct 0 ms 2408 KB Output is correct
16 Correct 0 ms 2408 KB Output is correct
17 Correct 0 ms 2408 KB Output is correct
18 Correct 0 ms 2408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2408 KB Output is correct
2 Correct 0 ms 2408 KB Output is correct
3 Correct 0 ms 2408 KB Output is correct
4 Correct 0 ms 2408 KB Output is correct
5 Correct 0 ms 2408 KB Output is correct
6 Correct 0 ms 2408 KB Output is correct
7 Correct 0 ms 2408 KB Output is correct
8 Correct 0 ms 2408 KB Output is correct
9 Correct 0 ms 2408 KB Output is correct
10 Correct 0 ms 2408 KB Output is correct
11 Correct 0 ms 2408 KB Output is correct
12 Correct 0 ms 2408 KB Output is correct
13 Correct 0 ms 2408 KB Output is correct
14 Correct 0 ms 2408 KB Output is correct
15 Correct 0 ms 2408 KB Output is correct
16 Correct 0 ms 2408 KB Output is correct
17 Correct 0 ms 2408 KB Output is correct
18 Correct 0 ms 2408 KB Output is correct
19 Correct 0 ms 2408 KB Output is correct
20 Correct 0 ms 2408 KB Output is correct
21 Correct 0 ms 2408 KB Output is correct
22 Correct 0 ms 2408 KB Output is correct
23 Correct 0 ms 2408 KB Output is correct
24 Correct 0 ms 2408 KB Output is correct
25 Correct 0 ms 2408 KB Output is correct
26 Correct 0 ms 2408 KB Output is correct
27 Correct 0 ms 2408 KB Output is correct
28 Correct 0 ms 2408 KB Output is correct
29 Correct 0 ms 2408 KB Output is correct
30 Correct 0 ms 2540 KB Output is correct