답안 #533764

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
533764 2022-03-07T07:14:05 Z PixelCat Worst Reporter 4 (JOI21_worst_reporter4) C++14
14 / 100
156 ms 196740 KB
/*       code by the cute PixelCat owo       */
/*   as cute as nacho neko (aka. my wife)!   */
// #pragma GCC
// optimize("O4,unroll-loops,no-stack-protector")
#include <bits/stdc++.h>
#define int LL  //__int128
#define double long double
using namespace std;
using LL = long long;
using uLL = unsigned long long;
using pii = pair<int, int>;

#define For(i, a, b) for (int i = a; i <= b; i++)
#define Fors(i, a, b, s) for (int i = a; i <= b; i += s)
#define Forr(i, a, b) for (int i = a; i >= b; i--)
#define F first
#define S second
#define L(id) (id * 2 + 1)
#define R(id) (id * 2 + 2)
#define LO(x) (x & (-x))

#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) ((int)x.size())
#define mkp make_pair

// #define MOD (int)(998244353)
#define MOD (int)(1e9 + 7)
#define INF (int)(9000000000000000000ll)  // 9e18
#define EPS (1e-6)

#ifdef NYAOWO
#include "library/debug.hpp"
inline void USACO(const string &s) {
    cerr << "USACO: " << s << "\n";
}

#else
#define debug(...)
inline void timer() {}
inline void USACO(const string &s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}

#endif

inline void NYA() {
    ios::sync_with_stdio(false);
    cin.tie(0);
}
inline int gcd(int a, int b) {
    return __gcd(a, b);
}
inline int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}
int fpow(int b, int p, const int &mod) {
    int ans = 1;
    while (p) {
        if (p & 1) ans = ans * b % mod;
        p /= 2;
        b = b * b % mod;
    }
    return ans;
}
int fpow(int b, int p) {
    return fpow(b, p, MOD);
}
template <typename T>
inline void chmin(T &_a, const T &_b) {
    if (_b < _a) _a = _b;
}
template <typename T>
inline void chmax(T &_a, const T &_b) {
    if (_b > _a) _a = _b;
}
// mt19937_64 rng(
//     chrono::steady_clock::now().time_since_epoch().count());

const int MAXN=5010;

int a[MAXN];
int x[MAXN];
int c[MAXN];
int dp[MAXN][MAXN];

int32_t main() {
    NYA();
    // nyaacho >/////<
    // miku sama bless me >/////<
    int n; cin>>n;
    vector<int> al;
    For(i,1,n){
        cin>>a[i]>>x[i]>>c[i];
        al.eb(x[i]);
    }
    sort(all(al));
    al.erase(unique(all(al)),al.end());
    int m=sz(al);
    For(i,1,n){
        x[i]=upper_bound(all(al),x[i])-al.begin();
        For(j,1,m) if(j!=x[i]) dp[i][j]=c[i];
    }
    Forr(i,n,2){
        Forr(j,m-1,1) chmin(dp[i][j],dp[i][j+1]);
        For(j,1,m) dp[a[i]][j]+=dp[i][j];
    }
    int ans=INF;
    For(i,1,m) chmin(ans,dp[1][i]);
    cout<<ans<<"\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 320 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 316 KB Output is correct
5 Correct 145 ms 196544 KB Output is correct
6 Correct 13 ms 24828 KB Output is correct
7 Correct 10 ms 21384 KB Output is correct
8 Correct 156 ms 196712 KB Output is correct
9 Correct 14 ms 24836 KB Output is correct
10 Correct 10 ms 21304 KB Output is correct
11 Correct 7 ms 10896 KB Output is correct
12 Correct 139 ms 196648 KB Output is correct
13 Correct 11 ms 21340 KB Output is correct
14 Correct 138 ms 196680 KB Output is correct
15 Correct 14 ms 24840 KB Output is correct
16 Correct 142 ms 196676 KB Output is correct
17 Correct 14 ms 24896 KB Output is correct
18 Correct 7 ms 11012 KB Output is correct
19 Correct 140 ms 196676 KB Output is correct
20 Correct 13 ms 24900 KB Output is correct
21 Correct 10 ms 21144 KB Output is correct
22 Correct 153 ms 196628 KB Output is correct
23 Correct 13 ms 24896 KB Output is correct
24 Correct 148 ms 196740 KB Output is correct
25 Correct 14 ms 24904 KB Output is correct
26 Correct 135 ms 196664 KB Output is correct
27 Correct 149 ms 196676 KB Output is correct
28 Correct 156 ms 196676 KB Output is correct
29 Correct 148 ms 196676 KB Output is correct
30 Correct 137 ms 196544 KB Output is correct
31 Correct 144 ms 196728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 320 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 316 KB Output is correct
5 Correct 145 ms 196544 KB Output is correct
6 Correct 13 ms 24828 KB Output is correct
7 Correct 10 ms 21384 KB Output is correct
8 Correct 156 ms 196712 KB Output is correct
9 Correct 14 ms 24836 KB Output is correct
10 Correct 10 ms 21304 KB Output is correct
11 Correct 7 ms 10896 KB Output is correct
12 Correct 139 ms 196648 KB Output is correct
13 Correct 11 ms 21340 KB Output is correct
14 Correct 138 ms 196680 KB Output is correct
15 Correct 14 ms 24840 KB Output is correct
16 Correct 142 ms 196676 KB Output is correct
17 Correct 14 ms 24896 KB Output is correct
18 Correct 7 ms 11012 KB Output is correct
19 Correct 140 ms 196676 KB Output is correct
20 Correct 13 ms 24900 KB Output is correct
21 Correct 10 ms 21144 KB Output is correct
22 Correct 153 ms 196628 KB Output is correct
23 Correct 13 ms 24896 KB Output is correct
24 Correct 148 ms 196740 KB Output is correct
25 Correct 14 ms 24904 KB Output is correct
26 Correct 135 ms 196664 KB Output is correct
27 Correct 149 ms 196676 KB Output is correct
28 Correct 156 ms 196676 KB Output is correct
29 Correct 148 ms 196676 KB Output is correct
30 Correct 137 ms 196544 KB Output is correct
31 Correct 144 ms 196728 KB Output is correct
32 Correct 148 ms 196680 KB Output is correct
33 Runtime error 5 ms 1224 KB Execution killed with signal 11
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 320 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 316 KB Output is correct
5 Correct 145 ms 196544 KB Output is correct
6 Correct 13 ms 24828 KB Output is correct
7 Correct 10 ms 21384 KB Output is correct
8 Correct 156 ms 196712 KB Output is correct
9 Correct 14 ms 24836 KB Output is correct
10 Correct 10 ms 21304 KB Output is correct
11 Correct 7 ms 10896 KB Output is correct
12 Correct 139 ms 196648 KB Output is correct
13 Correct 11 ms 21340 KB Output is correct
14 Correct 138 ms 196680 KB Output is correct
15 Correct 14 ms 24840 KB Output is correct
16 Correct 142 ms 196676 KB Output is correct
17 Correct 14 ms 24896 KB Output is correct
18 Correct 7 ms 11012 KB Output is correct
19 Correct 140 ms 196676 KB Output is correct
20 Correct 13 ms 24900 KB Output is correct
21 Correct 10 ms 21144 KB Output is correct
22 Correct 153 ms 196628 KB Output is correct
23 Correct 13 ms 24896 KB Output is correct
24 Correct 148 ms 196740 KB Output is correct
25 Correct 14 ms 24904 KB Output is correct
26 Correct 135 ms 196664 KB Output is correct
27 Correct 149 ms 196676 KB Output is correct
28 Correct 156 ms 196676 KB Output is correct
29 Correct 148 ms 196676 KB Output is correct
30 Correct 137 ms 196544 KB Output is correct
31 Correct 144 ms 196728 KB Output is correct
32 Correct 148 ms 196680 KB Output is correct
33 Runtime error 5 ms 1224 KB Execution killed with signal 11
34 Halted 0 ms 0 KB -