193982025-12-08 10:11:55ercseferencVárosnézéscpp17Runtime error 20/80574ms262144 KiB
#include <bits/stdc++.h>
using namespace std;
struct ter{vector<int>kim; int lat,elo;
    long long ert=0;};
int n,m; vector<ter>a;
int main()
{
    //ifstream f("szamok.txt");
    cin>>n>>m; a.resize(n+1);
    for(int i=1; i<=n; i++)cin>>a[i].lat;
    for(int i=0; i<m; i++){
        int x,y; cin>>x>>y;
        a[x].kim.push_back(y);}
    queue<int>q; q.push(1); a[1].ert=a[1].lat;
    while(!q.empty()){
        int r=q.front();
        for(int i:a[r].kim){
            if(a[i].ert<a[r].ert+a[i].lat){
                a[i].ert=a[r].ert+a[i].lat;
                q.push(i); a[i].elo=r;}}
        q.pop();}
    cout<<a[n].ert<<endl; int t=n; vector<int>ut;
    ut.push_back(n);
    while(t!=1){
        t=a[t].elo;
        ut.push_back(t);}
    for(int i=ut.size()-1; i>=0; i--)cout<<ut[i]<<" ";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted1ms500 KiB
subtask220/20
2Accepted1ms316 KiB
3Accepted1ms316 KiB
4Accepted1ms316 KiB
5Accepted4ms564 KiB
6Accepted3ms316 KiB
7Accepted8ms828 KiB
8Accepted8ms820 KiB
9Accepted1ms316 KiB
10Accepted14ms1368 KiB
11Accepted1ms508 KiB
12Accepted1ms316 KiB
subtask30/25
13Accepted1ms316 KiB
14Accepted1ms316 KiB
15Accepted1ms316 KiB
16Accepted1ms508 KiB
17Accepted1ms316 KiB
18Accepted1ms316 KiB
19Accepted1ms316 KiB
20Runtime error442ms262144 KiB
21Runtime error551ms262144 KiB
22Accepted4ms316 KiB
23Runtime error547ms262144 KiB
24Accepted4ms356 KiB
25Accepted2ms316 KiB
26Runtime error442ms262144 KiB
27Runtime error439ms262144 KiB
28Accepted28ms820 KiB
29Accepted6ms316 KiB
30Accepted28ms1332 KiB
31Runtime error561ms262144 KiB
32Runtime error574ms262144 KiB
33Runtime error446ms262144 KiB
subtask40/20
34Accepted1ms316 KiB
35Accepted1ms316 KiB
36Accepted1ms500 KiB
37Accepted2ms316 KiB
38Accepted1ms316 KiB
39Accepted1ms316 KiB
40Accepted1ms316 KiB
41Runtime error554ms262144 KiB
42Runtime error442ms262144 KiB
43Runtime error544ms262144 KiB
44Accepted1ms316 KiB
45Runtime error428ms262144 KiB
46Accepted1ms544 KiB
47Accepted1ms316 KiB
48Runtime error437ms262144 KiB
49Runtime error432ms262144 KiB
50Accepted2ms508 KiB
51Accepted1ms316 KiB
52Accepted1ms316 KiB
53Accepted1ms316 KiB
54Accepted1ms388 KiB
55Accepted1ms500 KiB
56Accepted1ms316 KiB
57Accepted1ms316 KiB
58Accepted1ms324 KiB
59Accepted1ms316 KiB
60Accepted1ms316 KiB
61Accepted1ms316 KiB
62Accepted1ms316 KiB
63Accepted1ms316 KiB
64Accepted1ms316 KiB
65Accepted1ms316 KiB
66Accepted1ms316 KiB
subtask50/15
67Accepted1ms316 KiB
68Accepted1ms316 KiB
69Accepted1ms316 KiB
70Accepted1ms316 KiB
71Accepted4ms564 KiB
72Accepted3ms316 KiB
73Accepted8ms828 KiB
74Accepted8ms820 KiB
75Accepted1ms316 KiB
76Accepted14ms1368 KiB
77Accepted1ms508 KiB
78Accepted1ms316 KiB
79Accepted1ms316 KiB
80Accepted1ms316 KiB
81Accepted1ms316 KiB
82Accepted1ms508 KiB
83Accepted1ms316 KiB
84Accepted1ms316 KiB
85Accepted1ms316 KiB
86Runtime error442ms262144 KiB
87Runtime error551ms262144 KiB
88Accepted4ms316 KiB
89Runtime error547ms262144 KiB
90Accepted4ms356 KiB
91Accepted2ms316 KiB
92Runtime error442ms262144 KiB
93Runtime error439ms262144 KiB
94Accepted28ms820 KiB
95Accepted6ms316 KiB
96Accepted28ms1332 KiB
97Runtime error561ms262144 KiB
98Runtime error574ms262144 KiB
99Runtime error446ms262144 KiB
100Accepted1ms316 KiB
101Accepted1ms500 KiB
102Accepted2ms316 KiB
103Accepted1ms316 KiB
104Accepted1ms316 KiB
105Accepted1ms316 KiB
106Runtime error554ms262144 KiB
107Runtime error442ms262144 KiB
108Runtime error544ms262144 KiB
109Accepted1ms316 KiB
110Runtime error428ms262144 KiB
111Accepted1ms544 KiB
112Accepted1ms316 KiB
113Runtime error437ms262144 KiB
114Runtime error432ms262144 KiB
115Accepted2ms508 KiB
116Accepted1ms316 KiB
117Accepted1ms316 KiB
118Accepted1ms316 KiB
119Accepted1ms388 KiB
120Accepted1ms500 KiB
121Accepted1ms316 KiB
122Accepted1ms316 KiB
123Accepted1ms324 KiB
124Accepted1ms316 KiB
125Accepted1ms316 KiB
126Accepted1ms316 KiB
127Accepted1ms316 KiB
128Accepted1ms316 KiB
129Accepted1ms316 KiB
130Accepted1ms316 KiB
131Accepted1ms316 KiB
132Accepted4ms316 KiB
133Runtime error432ms262144 KiB
134Accepted4ms500 KiB
135Accepted3ms316 KiB
136Accepted3ms316 KiB
137Runtime error538ms262144 KiB
138Accepted3ms316 KiB
139Runtime error538ms262144 KiB
140Accepted4ms564 KiB
141Accepted3ms316 KiB
142Accepted8ms820 KiB
143Accepted10ms820 KiB
144Accepted13ms1076 KiB
145Accepted8ms820 KiB
146Accepted21ms1588 KiB
147Accepted28ms1336 KiB
148Accepted179ms1076 KiB
149Accepted93ms684 KiB