QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#755235#6606. The Boomsday ProjectLeoGTL 0ms3568kbC++232.8kb2024-11-16 16:49:162024-11-16 16:49:17

Judging History

你现在查看的是最新测评结果

  • [2024-11-16 16:49:17]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3568kb
  • [2024-11-16 16:49:16]
  • 提交

answer

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <numeric>


#define ll              long long 
#define F               first
# define S              second
#define all(v)          v.begin(),v.end()
#define ld              long double
#define pll             std::pair<ll,ll>
#define pi              std::pair<int,int>
#define vi              std::vector<int>
#define vll             std::vector<ll>
#define len(x)          (int)x.size()
#define vec(T)          std::vector<T>


template<typename T, typename = void>
struct is_printable : std::false_type {};

template<typename T>
struct is_printable<T, std::void_t<decltype(std::declval<std::ostream&>() << std::declval<T>())>> : std::true_type {};
template <typename T>
void print(const std::pair<T, T>& pair) {
    std::cout << "(" << pair.first << ", " << pair.second << ")";
}

// General print function
template <typename T>
void print(const T& val) {
    std::cout << val;
}

// Print function for std::vector
template <typename T>
void print(const std::vector<T>& vec) {
    std::cout << '[';
    int n = vec.size();
    for (int i = 0; i < n; i++) {
        print(vec[i]);
        if (i < n - 1) {
            std::cout << ",";
        }
    }
    std::cout << ']' << '\n';
}

// Variadic template print function
template<typename T, typename... Args>
void print(const T& t, const Args&... args) {
    print(t);
    std::cout << (is_printable<T>::value ? ' ' : '\0');
    print(args...);
    if (sizeof...(args) == 1 && is_printable<T>::value) std::cout << '\n';

}


struct card {
    ll d, k, c;
};

struct record {
    ll p, q;
};


int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n, m, l = 0, idx = 0;
    ll r;
    std::cin >> n >> m >> r;
    vec(card) c(n);
    vec(record) tmp(m);
    for (int i = 0; i < n; i++) {
        std::cin >> c[i].d >> c[i].k >> c[i].c;
    }
    for (int i = 0; i < m; i++) {
        std::cin >> tmp[i].p >> tmp[i].q;
        l += tmp[i].q;
    }
    vi rec(l);
    std::sort(all(tmp), [&](record i, record j) {return i.p < j.p;});
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < tmp[i].q; j++) {
            rec[idx++] = tmp[i].p;
        }
    }
    vll dp(l + 1);
    for (int i = 0; i < l; i++) {
        dp[i + 1] = dp[i] + r;
        for (int j = 0; j < n; j++) {
            ll k = std::lower_bound(rec.begin(), rec.begin() + i, rec[i] - c[j].d + 1) - rec.begin();
            k = std::max(k, i - c[j].k + 1);
            dp[i + 1] = std::min(dp[i + 1], dp[k] + c[j].c);
        }    
    }
    std::cout << dp[l] << '\n';
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3568kb

input:

2 1 10
1 3 12
1 2 9
1 10

output:

42

result:

ok 1 number(s): "42"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

2 4 10
1 3 12
1 2 9
1 3
2 3
3 3
4 1

output:

45

result:

ok 1 number(s): "45"

Test #3:

score: -100
Time Limit Exceeded

input:

500 100 1000
95 20 20892
73 627 55354
52 747 1404314
19 676 597007
65 814 1569851
91 397 691575
81 4 4575
97 382 624404
21 197 201850
67 799 643576
27 895 1510533
3 800 552439
49 954 1149851
70 892 676406
82 882 1348956
1 318 324094
43 238 439111
94 397 471003
16 119 130686
1 637 77731
79 292 35234
...

output:


result: