답안 #652177

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
652177 2022-10-21T14:58:28 Z victor_gao Worst Reporter 4 (JOI21_worst_reporter4) C++17
14 / 100
620 ms 221764 KB
//#pragma GCC optimize("Ofast,unroll-loops,O3")
//#pragma GCC optimize("avx,avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,fma,tune=native")
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//#pragma pack(1)
#define fast ios::sync_with_stdio(0); cin.tie(0);
#define int long long
#define pii pair<int,int>
#define x first
#define y second
#define N 5015
using namespace std;
//using namespace __gnu_pbds;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> order_multiset;
//typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> order_set;
struct lisan{
    vector<int>vt;
    void in(int x){ vt.push_back(x); }
    void build(){
        sort(vt.begin(),vt.end());
        vt.resize(unique(vt.begin(),vt.end())-vt.begin());
    }
    int find(int x){ return upper_bound(vt.begin(),vt.end(),x)-vt.begin(); }
}uni;
int dp[N][N],a[N],h[N],c[N],n;
bool vis[N][N];
vector<int>g[N];
int DP(int i,int j){
    if (vis[i][j]) return dp[i][j];
    vis[i][j]=1;
    dp[i][j]=1e18;
    int case1=1e18,case2=c[i];
    if (h[i]>=j){
        case1=0;
        for (auto nxt:g[i]){
            if (nxt!=i){
                case1+=DP(nxt,h[i]);
            }
        }
    }
    for (auto nxt:g[i]){
        if (nxt!=i){
            case2+=DP(nxt,j);
        }
    }
    dp[i][j]=min(case1,case2);
    return dp[i][j];
}
signed main(){
    fast
    cin>>n;
    for (int i=1;i<=n;i++){
        cin>>a[i]>>h[i]>>c[i];
        g[a[i]].push_back(i);
        uni.in(h[i]);
    }
    uni.build();
    for (int i=1;i<=n;i++)
        h[i]=uni.find(h[i]);
    int ans=0;
    cout<<DP(1,0)<<'\n';
}

Compilation message

worst_reporter2.cpp: In function 'int main()':
worst_reporter2.cpp:61:9: warning: unused variable 'ans' [-Wunused-variable]
   61 |     int ans=0;
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 452 KB Output is correct
5 Correct 71 ms 149692 KB Output is correct
6 Correct 29 ms 45528 KB Output is correct
7 Correct 24 ms 41628 KB Output is correct
8 Correct 62 ms 141804 KB Output is correct
9 Correct 28 ms 45104 KB Output is correct
10 Correct 27 ms 41548 KB Output is correct
11 Correct 26 ms 41292 KB Output is correct
12 Correct 544 ms 221764 KB Output is correct
13 Correct 26 ms 42060 KB Output is correct
14 Correct 324 ms 221168 KB Output is correct
15 Correct 44 ms 45816 KB Output is correct
16 Correct 83 ms 166528 KB Output is correct
17 Correct 33 ms 45256 KB Output is correct
18 Correct 25 ms 41200 KB Output is correct
19 Correct 372 ms 221388 KB Output is correct
20 Correct 52 ms 45780 KB Output is correct
21 Correct 26 ms 41568 KB Output is correct
22 Correct 34 ms 65612 KB Output is correct
23 Correct 27 ms 44952 KB Output is correct
24 Correct 565 ms 221508 KB Output is correct
25 Correct 45 ms 45772 KB Output is correct
26 Correct 463 ms 143096 KB Output is correct
27 Correct 238 ms 148312 KB Output is correct
28 Correct 453 ms 163624 KB Output is correct
29 Correct 620 ms 157268 KB Output is correct
30 Correct 299 ms 142796 KB Output is correct
31 Correct 267 ms 142784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 452 KB Output is correct
5 Correct 71 ms 149692 KB Output is correct
6 Correct 29 ms 45528 KB Output is correct
7 Correct 24 ms 41628 KB Output is correct
8 Correct 62 ms 141804 KB Output is correct
9 Correct 28 ms 45104 KB Output is correct
10 Correct 27 ms 41548 KB Output is correct
11 Correct 26 ms 41292 KB Output is correct
12 Correct 544 ms 221764 KB Output is correct
13 Correct 26 ms 42060 KB Output is correct
14 Correct 324 ms 221168 KB Output is correct
15 Correct 44 ms 45816 KB Output is correct
16 Correct 83 ms 166528 KB Output is correct
17 Correct 33 ms 45256 KB Output is correct
18 Correct 25 ms 41200 KB Output is correct
19 Correct 372 ms 221388 KB Output is correct
20 Correct 52 ms 45780 KB Output is correct
21 Correct 26 ms 41568 KB Output is correct
22 Correct 34 ms 65612 KB Output is correct
23 Correct 27 ms 44952 KB Output is correct
24 Correct 565 ms 221508 KB Output is correct
25 Correct 45 ms 45772 KB Output is correct
26 Correct 463 ms 143096 KB Output is correct
27 Correct 238 ms 148312 KB Output is correct
28 Correct 453 ms 163624 KB Output is correct
29 Correct 620 ms 157268 KB Output is correct
30 Correct 299 ms 142796 KB Output is correct
31 Correct 267 ms 142784 KB Output is correct
32 Correct 77 ms 155724 KB Output is correct
33 Runtime error 153 ms 29056 KB Execution killed with signal 11
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 452 KB Output is correct
5 Correct 71 ms 149692 KB Output is correct
6 Correct 29 ms 45528 KB Output is correct
7 Correct 24 ms 41628 KB Output is correct
8 Correct 62 ms 141804 KB Output is correct
9 Correct 28 ms 45104 KB Output is correct
10 Correct 27 ms 41548 KB Output is correct
11 Correct 26 ms 41292 KB Output is correct
12 Correct 544 ms 221764 KB Output is correct
13 Correct 26 ms 42060 KB Output is correct
14 Correct 324 ms 221168 KB Output is correct
15 Correct 44 ms 45816 KB Output is correct
16 Correct 83 ms 166528 KB Output is correct
17 Correct 33 ms 45256 KB Output is correct
18 Correct 25 ms 41200 KB Output is correct
19 Correct 372 ms 221388 KB Output is correct
20 Correct 52 ms 45780 KB Output is correct
21 Correct 26 ms 41568 KB Output is correct
22 Correct 34 ms 65612 KB Output is correct
23 Correct 27 ms 44952 KB Output is correct
24 Correct 565 ms 221508 KB Output is correct
25 Correct 45 ms 45772 KB Output is correct
26 Correct 463 ms 143096 KB Output is correct
27 Correct 238 ms 148312 KB Output is correct
28 Correct 453 ms 163624 KB Output is correct
29 Correct 620 ms 157268 KB Output is correct
30 Correct 299 ms 142796 KB Output is correct
31 Correct 267 ms 142784 KB Output is correct
32 Correct 77 ms 155724 KB Output is correct
33 Runtime error 153 ms 29056 KB Execution killed with signal 11
34 Halted 0 ms 0 KB -