답안 #518959

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
518959 2022-01-25T09:29:40 Z alirezasamimi100 Worst Reporter 4 (JOI21_worst_reporter4) C++17
14 / 100
393 ms 196932 KB
/*#pragma GCC optimize("Ofast,unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")*/
/*#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma")*/
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using pll=pair<ll,ll>;
using pii=pair<int,int>;
using point=complex<double>;
#define F first
#define S second
//#define X real()
//#define Y imag()
#define pb push_back
#define mp make_pair
#define lc v<<1
#define rc v<<1|1
#define fast_io ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define kill(x) cout << x << '\n';exit(0)
#define killshayan kill("done!")
#define killmashtali kill("Hello, World!")
const int N=5e3+10,LN=19,M=3e2+10,SQ=450,BS=737,inf=1e9,NSQ=N/SQ+1;
const ll INF=1e18;
const double pi=acos(-1);
const ld ep=1e-7;
const int MH=1000696969,MD=998244353,MOD=1000000007;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pii, null_type,greater<pii>, rb_tree_tag,tree_order_statistics_node_update>
ll pow(ll x, ll y, ll mod){
    ll ans=1;
    while (y != 0) {
        if (y & 1) ans = ans * x % mod;
        y >>= 1;
        x = x * x % mod;
    }
    return ans;
}
ll n,dp[N][N],a[N],c[N];
vector<ll> adj[N],cp;
void dfs(ll v){
    for(ll u : adj[v]) dfs(u);
    for(ll i=cp.size()-1; i>=0; i--){
        if(i!=a[v]) dp[v][i]=c[v];
        for(ll u : adj[v]){
            dp[v][i]+=dp[u][i];
        }
        if(i<cp.size()-1) dp[v][i]=min(dp[v][i],dp[v][i+1]);
    }
}
int main(){
    fast_io;
    cin >> n;
    for(ll i=1; i<=n; i++){
        ll p;
        cin >> p >> a[i] >> c[i];
        if(i>1) adj[p].pb(i);
        cp.pb(a[i]);
    }
    sort(cp.begin(),cp.end());
    cp.resize(unique(cp.begin(),cp.end())-cp.begin());
    for(ll i=1; i<=n; i++) a[i]=lower_bound(cp.begin(),cp.end(),a[i])-cp.begin();
    dfs(1);
    cout << dp[1][0] << '\n';
    return 0;
}

Compilation message

worst_reporter2.cpp: In function 'void dfs(ll)':
worst_reporter2.cpp:54:13: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |         if(i<cp.size()-1) dp[v][i]=min(dp[v][i],dp[v][i+1]);
      |            ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 159 ms 196572 KB Output is correct
6 Correct 15 ms 24752 KB Output is correct
7 Correct 11 ms 21240 KB Output is correct
8 Correct 159 ms 196676 KB Output is correct
9 Correct 14 ms 24828 KB Output is correct
10 Correct 12 ms 21356 KB Output is correct
11 Correct 9 ms 10828 KB Output is correct
12 Correct 155 ms 196892 KB Output is correct
13 Correct 10 ms 21648 KB Output is correct
14 Correct 157 ms 196788 KB Output is correct
15 Correct 13 ms 25036 KB Output is correct
16 Correct 168 ms 196764 KB Output is correct
17 Correct 14 ms 24780 KB Output is correct
18 Correct 9 ms 10956 KB Output is correct
19 Correct 156 ms 196844 KB Output is correct
20 Correct 14 ms 24952 KB Output is correct
21 Correct 11 ms 21292 KB Output is correct
22 Correct 393 ms 196724 KB Output is correct
23 Correct 20 ms 24780 KB Output is correct
24 Correct 265 ms 196860 KB Output is correct
25 Correct 15 ms 24968 KB Output is correct
26 Correct 163 ms 196916 KB Output is correct
27 Correct 160 ms 196816 KB Output is correct
28 Correct 159 ms 196904 KB Output is correct
29 Correct 159 ms 196932 KB Output is correct
30 Correct 162 ms 196704 KB Output is correct
31 Correct 157 ms 196832 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 159 ms 196572 KB Output is correct
6 Correct 15 ms 24752 KB Output is correct
7 Correct 11 ms 21240 KB Output is correct
8 Correct 159 ms 196676 KB Output is correct
9 Correct 14 ms 24828 KB Output is correct
10 Correct 12 ms 21356 KB Output is correct
11 Correct 9 ms 10828 KB Output is correct
12 Correct 155 ms 196892 KB Output is correct
13 Correct 10 ms 21648 KB Output is correct
14 Correct 157 ms 196788 KB Output is correct
15 Correct 13 ms 25036 KB Output is correct
16 Correct 168 ms 196764 KB Output is correct
17 Correct 14 ms 24780 KB Output is correct
18 Correct 9 ms 10956 KB Output is correct
19 Correct 156 ms 196844 KB Output is correct
20 Correct 14 ms 24952 KB Output is correct
21 Correct 11 ms 21292 KB Output is correct
22 Correct 393 ms 196724 KB Output is correct
23 Correct 20 ms 24780 KB Output is correct
24 Correct 265 ms 196860 KB Output is correct
25 Correct 15 ms 24968 KB Output is correct
26 Correct 163 ms 196916 KB Output is correct
27 Correct 160 ms 196816 KB Output is correct
28 Correct 159 ms 196904 KB Output is correct
29 Correct 159 ms 196932 KB Output is correct
30 Correct 162 ms 196704 KB Output is correct
31 Correct 157 ms 196832 KB Output is correct
32 Correct 162 ms 196752 KB Output is correct
33 Runtime error 5 ms 1100 KB Execution killed with signal 11
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 159 ms 196572 KB Output is correct
6 Correct 15 ms 24752 KB Output is correct
7 Correct 11 ms 21240 KB Output is correct
8 Correct 159 ms 196676 KB Output is correct
9 Correct 14 ms 24828 KB Output is correct
10 Correct 12 ms 21356 KB Output is correct
11 Correct 9 ms 10828 KB Output is correct
12 Correct 155 ms 196892 KB Output is correct
13 Correct 10 ms 21648 KB Output is correct
14 Correct 157 ms 196788 KB Output is correct
15 Correct 13 ms 25036 KB Output is correct
16 Correct 168 ms 196764 KB Output is correct
17 Correct 14 ms 24780 KB Output is correct
18 Correct 9 ms 10956 KB Output is correct
19 Correct 156 ms 196844 KB Output is correct
20 Correct 14 ms 24952 KB Output is correct
21 Correct 11 ms 21292 KB Output is correct
22 Correct 393 ms 196724 KB Output is correct
23 Correct 20 ms 24780 KB Output is correct
24 Correct 265 ms 196860 KB Output is correct
25 Correct 15 ms 24968 KB Output is correct
26 Correct 163 ms 196916 KB Output is correct
27 Correct 160 ms 196816 KB Output is correct
28 Correct 159 ms 196904 KB Output is correct
29 Correct 159 ms 196932 KB Output is correct
30 Correct 162 ms 196704 KB Output is correct
31 Correct 157 ms 196832 KB Output is correct
32 Correct 162 ms 196752 KB Output is correct
33 Runtime error 5 ms 1100 KB Execution killed with signal 11
34 Halted 0 ms 0 KB -