# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
419482 | 2021-06-07T07:40:36 Z | juggernaut | Election Campaign (JOI15_election_campaign) | C++17 | 93 ms | 4680 KB |
#include<bits/stdc++.h> #define fr first #define sc second using namespace std; void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);} typedef long long ll; #define USING_ORDERED_SET 0 #if USING_ORDERED_SET #include<bits/extc++.h> using namespace __gnu_pbds; template<class T>using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; #endif template<class T>void umax(T &a,T b){if(a<b)a=b;} template<class T>void umin(T &a,T b){if(b<a)a=b;} #ifdef IOI2021SG #define printl(args...)printf(args) #else #define printl(args...)((void)0) #endif int n; vector<pair<int,int>>g[100005]; int dp[100005]; int m; int main(){ scanf("%d",&n); for(int i=1,x;i<n;i++)scanf("%d%d",&x,&x); scanf("%d",&m); while(m--){ int x,y,z; scanf("%d%d%d",&x,&y,&z); if(x>y)swap(x,y); g[y].emplace_back(x,z); } for(int i=1;i<=n;i++){ dp[i]=dp[i-1]; for(auto to:g[i])umax(dp[i],dp[to.fr-1]+to.sc); } printf("%d",dp[n]); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 2636 KB | Output is correct |
2 | Correct | 3 ms | 2636 KB | Output is correct |
3 | Incorrect | 2 ms | 2636 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2636 KB | Output is correct |
2 | Correct | 2 ms | 2636 KB | Output is correct |
3 | Correct | 3 ms | 2636 KB | Output is correct |
4 | Correct | 62 ms | 4556 KB | Output is correct |
5 | Correct | 62 ms | 4540 KB | Output is correct |
6 | Correct | 65 ms | 4620 KB | Output is correct |
7 | Correct | 67 ms | 4528 KB | Output is correct |
8 | Correct | 59 ms | 4556 KB | Output is correct |
9 | Correct | 62 ms | 4556 KB | Output is correct |
10 | Correct | 66 ms | 4680 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2636 KB | Output is correct |
2 | Correct | 2 ms | 2636 KB | Output is correct |
3 | Correct | 3 ms | 2636 KB | Output is correct |
4 | Correct | 62 ms | 4556 KB | Output is correct |
5 | Correct | 62 ms | 4540 KB | Output is correct |
6 | Correct | 65 ms | 4620 KB | Output is correct |
7 | Correct | 67 ms | 4528 KB | Output is correct |
8 | Correct | 59 ms | 4556 KB | Output is correct |
9 | Correct | 62 ms | 4556 KB | Output is correct |
10 | Correct | 66 ms | 4680 KB | Output is correct |
11 | Correct | 9 ms | 2948 KB | Output is correct |
12 | Correct | 64 ms | 4528 KB | Output is correct |
13 | Correct | 93 ms | 4496 KB | Output is correct |
14 | Correct | 67 ms | 4612 KB | Output is correct |
15 | Correct | 64 ms | 4508 KB | Output is correct |
16 | Correct | 64 ms | 4544 KB | Output is correct |
17 | Correct | 61 ms | 4560 KB | Output is correct |
18 | Correct | 70 ms | 4552 KB | Output is correct |
19 | Correct | 69 ms | 4540 KB | Output is correct |
20 | Correct | 75 ms | 4504 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 64 ms | 4544 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 2636 KB | Output is correct |
2 | Correct | 3 ms | 2636 KB | Output is correct |
3 | Incorrect | 2 ms | 2636 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 2636 KB | Output is correct |
2 | Correct | 3 ms | 2636 KB | Output is correct |
3 | Incorrect | 2 ms | 2636 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |