답안 #1098952

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1098952 2024-10-10T11:15:27 Z AliHasanli Cheap flights (LMIO18_pigus_skrydziai) C++17
37 / 100
3000 ms 45880 KB
#include <bits/stdc++.h>
using namespace std;
long long selected[300001];
vector<pair<pair<int,int>,long long> >edges;
vector<pair<int,long long> >g[300001];
int main()
{
    int n,m;
    long long ans=0;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int a,b;
        long long p;
        cin>>a>>b>>p;
        edges.push_back({{a,b},p});
        g[a].push_back({b,p});
        g[b].push_back({a,p});
    }
    for(int i=1;i<=n;i++)
    {
        long long sum=0;
        for(pair<int,long long>go:g[i])sum+=go.second;
        ans=max(ans,sum);
    }
    for(pair<pair<int,int>,long long>edge:edges)
    {
        long long sum=edge.second;
        for(pair<int,long long>go:g[edge.first.first])selected[go.first]=go.second;
        for(pair<int,long long>go:g[edge.first.second])if(selected[go.first]>0)sum=max(sum,edge.second+go.second+selected[go.first]);
        for(pair<int,long long>go:g[edge.first.first])selected[go.first]=0;
        ans=max(ans,sum);
    }
    cout<<ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 7256 KB Output is correct
2 Correct 3 ms 7260 KB Output is correct
3 Correct 3 ms 7260 KB Output is correct
4 Correct 3 ms 7256 KB Output is correct
5 Correct 3 ms 7256 KB Output is correct
6 Correct 26 ms 8920 KB Output is correct
7 Correct 3 ms 7260 KB Output is correct
8 Correct 3 ms 7512 KB Output is correct
9 Correct 3 ms 7260 KB Output is correct
10 Correct 4 ms 7280 KB Output is correct
11 Correct 3 ms 7516 KB Output is correct
12 Correct 3 ms 7460 KB Output is correct
13 Correct 3 ms 7260 KB Output is correct
14 Correct 3 ms 7260 KB Output is correct
15 Correct 3 ms 7260 KB Output is correct
16 Correct 3 ms 7492 KB Output is correct
17 Correct 3 ms 7444 KB Output is correct
18 Correct 4 ms 7516 KB Output is correct
19 Correct 4 ms 7512 KB Output is correct
20 Correct 3 ms 7260 KB Output is correct
21 Correct 3 ms 7260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 7256 KB Output is correct
2 Correct 3 ms 7260 KB Output is correct
3 Correct 3 ms 7260 KB Output is correct
4 Correct 3 ms 7256 KB Output is correct
5 Correct 3 ms 7256 KB Output is correct
6 Correct 26 ms 8920 KB Output is correct
7 Correct 3 ms 7260 KB Output is correct
8 Correct 3 ms 7512 KB Output is correct
9 Correct 3 ms 7260 KB Output is correct
10 Correct 4 ms 7280 KB Output is correct
11 Correct 3 ms 7516 KB Output is correct
12 Correct 3 ms 7460 KB Output is correct
13 Correct 3 ms 7260 KB Output is correct
14 Correct 3 ms 7260 KB Output is correct
15 Correct 3 ms 7260 KB Output is correct
16 Correct 3 ms 7492 KB Output is correct
17 Correct 3 ms 7444 KB Output is correct
18 Correct 4 ms 7516 KB Output is correct
19 Correct 4 ms 7512 KB Output is correct
20 Correct 3 ms 7260 KB Output is correct
21 Correct 3 ms 7260 KB Output is correct
22 Correct 635 ms 45880 KB Output is correct
23 Correct 1230 ms 40108 KB Output is correct
24 Correct 15 ms 9176 KB Output is correct
25 Correct 11 ms 7768 KB Output is correct
26 Correct 7 ms 7928 KB Output is correct
27 Correct 7 ms 7512 KB Output is correct
28 Correct 276 ms 22792 KB Output is correct
29 Correct 105 ms 14024 KB Output is correct
30 Correct 209 ms 15808 KB Output is correct
31 Correct 4 ms 7516 KB Output is correct
32 Correct 4 ms 7516 KB Output is correct
33 Correct 2101 ms 43436 KB Output is correct
34 Correct 1695 ms 38544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 104 ms 23740 KB Output is correct
2 Correct 226 ms 34472 KB Output is correct
3 Correct 64 ms 16312 KB Output is correct
4 Correct 125 ms 25012 KB Output is correct
5 Correct 232 ms 33704 KB Output is correct
6 Correct 158 ms 14528 KB Output is correct
7 Correct 140 ms 29204 KB Output is correct
8 Correct 166 ms 32996 KB Output is correct
9 Correct 6 ms 9304 KB Output is correct
10 Correct 161 ms 14652 KB Output is correct
11 Execution timed out 3078 ms 30604 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 104 ms 23740 KB Output is correct
2 Correct 226 ms 34472 KB Output is correct
3 Correct 64 ms 16312 KB Output is correct
4 Correct 125 ms 25012 KB Output is correct
5 Correct 232 ms 33704 KB Output is correct
6 Correct 158 ms 14528 KB Output is correct
7 Correct 140 ms 29204 KB Output is correct
8 Correct 166 ms 32996 KB Output is correct
9 Correct 6 ms 9304 KB Output is correct
10 Correct 161 ms 14652 KB Output is correct
11 Execution timed out 3078 ms 30604 KB Time limit exceeded
12 Halted 0 ms 0 KB -