# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
848326 | 2023-09-12T06:35:36 Z | KN200711 | Voting Cities (NOI22_votingcity) | C++14 | 171 ms | 10696 KB |
# include <bits/stdc++.h> # define ll long long # define fi first # define se second using namespace std; int N, E, K; vector<int> T; vector< pair<int, ll> > edge[5001]; ll dp[32][5001]; bool vis[32][5001]; int main() { scanf("%d %d %d", &N, &E, &K); T.resize(K); for(int i=0;i<K;i++) { scanf("%d", &T[i]); } for(int i=0;i<E;i++) { int a, b; ll c; scanf("%d %d %lld", &a, &b, &c); edge[b].push_back(make_pair(a, c)); } for(int i=0;i<32;i++) { for(int k=0;k<N;k++) dp[i][k] = -1; } priority_queue< pair<int, pair<ll, int> > > PQ; for(int i=0;i<K;i++) { PQ.push(make_pair(0, make_pair(0, T[i]))); } while(!PQ.empty()) { int a, c; ll b; a = -PQ.top().fi; b = -PQ.top().se.fi; c = PQ.top().se.se; PQ.pop(); if(dp[a][c] != -1) continue; // cout<<"a : "<<a<<" "<<c<<endl; dp[a][c] = b; for(auto p : edge[c]) { for(int k=0;k<5;k++) { if(!(a&(1 << k))) { if(dp[a^(1 << k)][c] == -1) PQ.push(make_pair(-(a ^ (1 << k)), make_pair(-b - (10 - k - 1) * p.se / 10, p.fi))); } } if(dp[a][p.fi] == -1) { PQ.push(make_pair(-a, make_pair(-b-p.se, p.fi))); } } } int Q; scanf("%d", &Q); while(Q--) { int S; ll P[5]; scanf("%d", &S); for(int i=0;i<5;i++) scanf("%lld", &P[i]); ll as = 0ll, ans = 1e18; for(int i=0;i<32;i++) { // cout<<"i : "<<i<<" "<<dp[i][S]<<endl; if(dp[i][S] == -1) continue; as = dp[i][S]; for(int k=0;k<5;k++) { if(i&(1 << k)) { if(P[k] == -1) { as = 1e18; break; } else as += P[k]; } } ans = min(ans, as); } if(ans >= 1e18) ans = -1; printf("%lld\n", ans); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 143 ms | 10180 KB | Output is correct |
2 | Correct | 91 ms | 6352 KB | Output is correct |
3 | Correct | 168 ms | 9928 KB | Output is correct |
4 | Correct | 1 ms | 600 KB | Output is correct |
5 | Correct | 1 ms | 600 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 143 ms | 10180 KB | Output is correct |
2 | Correct | 91 ms | 6352 KB | Output is correct |
3 | Correct | 168 ms | 9928 KB | Output is correct |
4 | Correct | 1 ms | 600 KB | Output is correct |
5 | Correct | 1 ms | 600 KB | Output is correct |
6 | Correct | 142 ms | 9672 KB | Output is correct |
7 | Correct | 91 ms | 5572 KB | Output is correct |
8 | Correct | 159 ms | 9416 KB | Output is correct |
9 | Correct | 1 ms | 592 KB | Output is correct |
10 | Correct | 0 ms | 600 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 143 ms | 10180 KB | Output is correct |
2 | Correct | 91 ms | 6352 KB | Output is correct |
3 | Correct | 168 ms | 9928 KB | Output is correct |
4 | Correct | 1 ms | 600 KB | Output is correct |
5 | Correct | 1 ms | 600 KB | Output is correct |
6 | Correct | 142 ms | 9672 KB | Output is correct |
7 | Correct | 91 ms | 5572 KB | Output is correct |
8 | Correct | 159 ms | 9416 KB | Output is correct |
9 | Correct | 1 ms | 592 KB | Output is correct |
10 | Correct | 0 ms | 600 KB | Output is correct |
11 | Correct | 150 ms | 10432 KB | Output is correct |
12 | Correct | 95 ms | 5068 KB | Output is correct |
13 | Correct | 161 ms | 9160 KB | Output is correct |
14 | Correct | 1 ms | 600 KB | Output is correct |
15 | Correct | 1 ms | 600 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 143 ms | 10180 KB | Output is correct |
2 | Correct | 91 ms | 6352 KB | Output is correct |
3 | Correct | 168 ms | 9928 KB | Output is correct |
4 | Correct | 1 ms | 600 KB | Output is correct |
5 | Correct | 1 ms | 600 KB | Output is correct |
6 | Correct | 4 ms | 2136 KB | Output is correct |
7 | Correct | 90 ms | 5068 KB | Output is correct |
8 | Correct | 165 ms | 9928 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 143 ms | 10180 KB | Output is correct |
2 | Correct | 91 ms | 6352 KB | Output is correct |
3 | Correct | 168 ms | 9928 KB | Output is correct |
4 | Correct | 1 ms | 600 KB | Output is correct |
5 | Correct | 1 ms | 600 KB | Output is correct |
6 | Correct | 142 ms | 9672 KB | Output is correct |
7 | Correct | 91 ms | 5572 KB | Output is correct |
8 | Correct | 159 ms | 9416 KB | Output is correct |
9 | Correct | 1 ms | 592 KB | Output is correct |
10 | Correct | 0 ms | 600 KB | Output is correct |
11 | Correct | 4 ms | 2136 KB | Output is correct |
12 | Correct | 90 ms | 5068 KB | Output is correct |
13 | Correct | 165 ms | 9928 KB | Output is correct |
14 | Correct | 150 ms | 10176 KB | Output is correct |
15 | Correct | 91 ms | 5068 KB | Output is correct |
16 | Correct | 171 ms | 8396 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 150 ms | 8900 KB | Output is correct |
2 | Correct | 149 ms | 8384 KB | Output is correct |
3 | Correct | 105 ms | 6376 KB | Output is correct |
4 | Correct | 163 ms | 9932 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 1620 KB | Output is correct |
2 | Correct | 15 ms | 1880 KB | Output is correct |
3 | Correct | 2 ms | 856 KB | Output is correct |
4 | Correct | 13 ms | 1624 KB | Output is correct |
5 | Correct | 13 ms | 1620 KB | Output is correct |
6 | Correct | 2 ms | 856 KB | Output is correct |
7 | Correct | 15 ms | 1632 KB | Output is correct |
8 | Correct | 15 ms | 1620 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 143 ms | 10180 KB | Output is correct |
2 | Correct | 91 ms | 6352 KB | Output is correct |
3 | Correct | 168 ms | 9928 KB | Output is correct |
4 | Correct | 1 ms | 600 KB | Output is correct |
5 | Correct | 1 ms | 600 KB | Output is correct |
6 | Correct | 142 ms | 9672 KB | Output is correct |
7 | Correct | 91 ms | 5572 KB | Output is correct |
8 | Correct | 159 ms | 9416 KB | Output is correct |
9 | Correct | 1 ms | 592 KB | Output is correct |
10 | Correct | 0 ms | 600 KB | Output is correct |
11 | Correct | 150 ms | 10432 KB | Output is correct |
12 | Correct | 95 ms | 5068 KB | Output is correct |
13 | Correct | 161 ms | 9160 KB | Output is correct |
14 | Correct | 1 ms | 600 KB | Output is correct |
15 | Correct | 1 ms | 600 KB | Output is correct |
16 | Correct | 4 ms | 2136 KB | Output is correct |
17 | Correct | 90 ms | 5068 KB | Output is correct |
18 | Correct | 165 ms | 9928 KB | Output is correct |
19 | Correct | 150 ms | 10176 KB | Output is correct |
20 | Correct | 91 ms | 5068 KB | Output is correct |
21 | Correct | 171 ms | 8396 KB | Output is correct |
22 | Correct | 150 ms | 8900 KB | Output is correct |
23 | Correct | 149 ms | 8384 KB | Output is correct |
24 | Correct | 105 ms | 6376 KB | Output is correct |
25 | Correct | 163 ms | 9932 KB | Output is correct |
26 | Correct | 15 ms | 1620 KB | Output is correct |
27 | Correct | 15 ms | 1880 KB | Output is correct |
28 | Correct | 2 ms | 856 KB | Output is correct |
29 | Correct | 13 ms | 1624 KB | Output is correct |
30 | Correct | 13 ms | 1620 KB | Output is correct |
31 | Correct | 2 ms | 856 KB | Output is correct |
32 | Correct | 15 ms | 1632 KB | Output is correct |
33 | Correct | 15 ms | 1620 KB | Output is correct |
34 | Correct | 1 ms | 600 KB | Output is correct |
35 | Correct | 0 ms | 600 KB | Output is correct |
36 | Correct | 0 ms | 600 KB | Output is correct |
37 | Correct | 152 ms | 8908 KB | Output is correct |
38 | Correct | 155 ms | 10176 KB | Output is correct |
39 | Correct | 162 ms | 10696 KB | Output is correct |
40 | Correct | 1 ms | 1624 KB | Output is correct |
41 | Correct | 3 ms | 2140 KB | Output is correct |
42 | Correct | 162 ms | 8896 KB | Output is correct |
43 | Correct | 164 ms | 8644 KB | Output is correct |
44 | Correct | 161 ms | 9152 KB | Output is correct |
45 | Correct | 105 ms | 5072 KB | Output is correct |