# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
810371 | 2023-08-06T08:53:33 Z | vjudge1 | Worst Reporter 4 (JOI21_worst_reporter4) | C++17 | 372 ms | 197040 KB |
#include <bits/stdc++.h> using namespace std; #define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define rall(s) s.rbegin(),s.rend() #define all(s) s.begin(),s.end() #define pb push_back #define fi first #define se second #define ll long long #define ld long double #define YES cout<<"YES\n" #define Yes cout<<"Yes\n" #define yes cout<<"yes\n" #define NO cout<<"NO\n" #define No cout<<"No\n" #define no cout<<"no\n" const int N = 5e3 + 9 , mod = 1e9 + 7; ll d[N] = {} , a[N] = {}, b[N] , c[N] , us[N] = {} , p[N] = {} , mp[N][N]; vector<ll>v[N] , v1[N]; void solve(){ ll q , i , j , m ,n, z ,s = 0 , f , l , r , k , x , y , mn = 1e18 , mx = 0; cin>>n; vector<ll>vc; for(i = 1; i <= n; i++){ cin>>a[i]>>b[i]>>c[i]; if(i != 1) v[a[i]].pb(i); vc.pb(b[i]); } sort(rall(vc)); for(i = n; i >= 1; i--){ if(v[i].size() == 0){ j = 0; for(auto to : vc){ if(to == b[i]) mp[i][j] = 0; else mp[i][j] = c[i]; j++; } continue; } for(auto to : v[i]) d[to] = 1e18; j = 0; for(auto it : vc){ s = 0; for(auto to : v[i]) d[to] = min(d[to] , mp[to][j]) ,s += d[to]; if(it == b[i]) mp[i][j] = s ; else mp[i][j] = c[i] + s; if(i == 1 && mp[i][j] < mn) mn = mp[i][j]; j++; } } cout<<mn<<"\n"; } int main(){ /* TL; #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif */ int t = 1; //cin>>t; while(t--) { solve(); } } // Author : حسن
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 468 KB | Output is correct |
2 | Correct | 0 ms | 468 KB | Output is correct |
3 | Correct | 0 ms | 468 KB | Output is correct |
4 | Correct | 0 ms | 468 KB | Output is correct |
5 | Correct | 121 ms | 196684 KB | Output is correct |
6 | Correct | 121 ms | 196904 KB | Output is correct |
7 | Correct | 125 ms | 196944 KB | Output is correct |
8 | Correct | 136 ms | 196984 KB | Output is correct |
9 | Correct | 123 ms | 196936 KB | Output is correct |
10 | Correct | 121 ms | 196964 KB | Output is correct |
11 | Correct | 125 ms | 196980 KB | Output is correct |
12 | Correct | 157 ms | 196952 KB | Output is correct |
13 | Correct | 141 ms | 197000 KB | Output is correct |
14 | Correct | 140 ms | 196940 KB | Output is correct |
15 | Correct | 142 ms | 196952 KB | Output is correct |
16 | Correct | 121 ms | 196924 KB | Output is correct |
17 | Correct | 119 ms | 196964 KB | Output is correct |
18 | Correct | 120 ms | 196952 KB | Output is correct |
19 | Correct | 134 ms | 196992 KB | Output is correct |
20 | Correct | 120 ms | 197000 KB | Output is correct |
21 | Correct | 132 ms | 196972 KB | Output is correct |
22 | Correct | 372 ms | 197008 KB | Output is correct |
23 | Correct | 366 ms | 196992 KB | Output is correct |
24 | Correct | 243 ms | 196964 KB | Output is correct |
25 | Correct | 211 ms | 196924 KB | Output is correct |
26 | Correct | 148 ms | 196948 KB | Output is correct |
27 | Correct | 136 ms | 196920 KB | Output is correct |
28 | Correct | 123 ms | 196968 KB | Output is correct |
29 | Correct | 133 ms | 196996 KB | Output is correct |
30 | Correct | 156 ms | 196884 KB | Output is correct |
31 | Correct | 147 ms | 197040 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 468 KB | Output is correct |
2 | Correct | 0 ms | 468 KB | Output is correct |
3 | Correct | 0 ms | 468 KB | Output is correct |
4 | Correct | 0 ms | 468 KB | Output is correct |
5 | Correct | 121 ms | 196684 KB | Output is correct |
6 | Correct | 121 ms | 196904 KB | Output is correct |
7 | Correct | 125 ms | 196944 KB | Output is correct |
8 | Correct | 136 ms | 196984 KB | Output is correct |
9 | Correct | 123 ms | 196936 KB | Output is correct |
10 | Correct | 121 ms | 196964 KB | Output is correct |
11 | Correct | 125 ms | 196980 KB | Output is correct |
12 | Correct | 157 ms | 196952 KB | Output is correct |
13 | Correct | 141 ms | 197000 KB | Output is correct |
14 | Correct | 140 ms | 196940 KB | Output is correct |
15 | Correct | 142 ms | 196952 KB | Output is correct |
16 | Correct | 121 ms | 196924 KB | Output is correct |
17 | Correct | 119 ms | 196964 KB | Output is correct |
18 | Correct | 120 ms | 196952 KB | Output is correct |
19 | Correct | 134 ms | 196992 KB | Output is correct |
20 | Correct | 120 ms | 197000 KB | Output is correct |
21 | Correct | 132 ms | 196972 KB | Output is correct |
22 | Correct | 372 ms | 197008 KB | Output is correct |
23 | Correct | 366 ms | 196992 KB | Output is correct |
24 | Correct | 243 ms | 196964 KB | Output is correct |
25 | Correct | 211 ms | 196924 KB | Output is correct |
26 | Correct | 148 ms | 196948 KB | Output is correct |
27 | Correct | 136 ms | 196920 KB | Output is correct |
28 | Correct | 123 ms | 196968 KB | Output is correct |
29 | Correct | 133 ms | 196996 KB | Output is correct |
30 | Correct | 156 ms | 196884 KB | Output is correct |
31 | Correct | 147 ms | 197040 KB | Output is correct |
32 | Correct | 119 ms | 196952 KB | Output is correct |
33 | Runtime error | 14 ms | 2480 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 | 0 ms | 468 KB | Output is correct |
3 | Correct | 0 ms | 468 KB | Output is correct |
4 | Correct | 0 ms | 468 KB | Output is correct |
5 | Correct | 121 ms | 196684 KB | Output is correct |
6 | Correct | 121 ms | 196904 KB | Output is correct |
7 | Correct | 125 ms | 196944 KB | Output is correct |
8 | Correct | 136 ms | 196984 KB | Output is correct |
9 | Correct | 123 ms | 196936 KB | Output is correct |
10 | Correct | 121 ms | 196964 KB | Output is correct |
11 | Correct | 125 ms | 196980 KB | Output is correct |
12 | Correct | 157 ms | 196952 KB | Output is correct |
13 | Correct | 141 ms | 197000 KB | Output is correct |
14 | Correct | 140 ms | 196940 KB | Output is correct |
15 | Correct | 142 ms | 196952 KB | Output is correct |
16 | Correct | 121 ms | 196924 KB | Output is correct |
17 | Correct | 119 ms | 196964 KB | Output is correct |
18 | Correct | 120 ms | 196952 KB | Output is correct |
19 | Correct | 134 ms | 196992 KB | Output is correct |
20 | Correct | 120 ms | 197000 KB | Output is correct |
21 | Correct | 132 ms | 196972 KB | Output is correct |
22 | Correct | 372 ms | 197008 KB | Output is correct |
23 | Correct | 366 ms | 196992 KB | Output is correct |
24 | Correct | 243 ms | 196964 KB | Output is correct |
25 | Correct | 211 ms | 196924 KB | Output is correct |
26 | Correct | 148 ms | 196948 KB | Output is correct |
27 | Correct | 136 ms | 196920 KB | Output is correct |
28 | Correct | 123 ms | 196968 KB | Output is correct |
29 | Correct | 133 ms | 196996 KB | Output is correct |
30 | Correct | 156 ms | 196884 KB | Output is correct |
31 | Correct | 147 ms | 197040 KB | Output is correct |
32 | Correct | 119 ms | 196952 KB | Output is correct |
33 | Runtime error | 14 ms | 2480 KB | Execution killed with signal 11 |
34 | Halted | 0 ms | 0 KB | - |