답안 #795924

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
795924 2023-07-27T22:36:13 Z allllekssssa Cheap flights (LMIO18_pigus_skrydziai) C++14
12 / 100
3000 ms 96956 KB
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

#define mp make_pair
#define pb push_back
#define pii pair<int, int>

const int maxN = 1e6 + 10;

vector<pii> v[maxN];
long long cnt[maxN];
map<pii, int> mapa;
int n, m;
int mx;

int main() {

    cin >> n >> m;
	

    for (int i = 1; i<=m; i++) {
    	int x, y, z;
    	scanf("%d%d%d", &x, &y, &z);
    	cnt[x]+=z;
    	cnt[y]+=z;
    	v[x].pb(mp(y,z));
    	v[y].pb(mp(x, z));
    	mapa[mp(x, y)] = z;
    	mapa[mp(y, x)] = z;
    	mx = max(mx, z);
    }


    long long ans = 0;

    for (int i = 1; i<=n; i++) {
    	ans = max(ans, cnt[i]);
    }

    if (mx > 1) {

    for (int x = 1; x<=n; x++) {
    	for (auto y : v[x]) {
    	for (auto z: v[y.first]) {
    			if (mapa.count(mp(x, z.first)))
    			ans = max(ans, 1ll * y.second + z.second + mapa[mp(x, z.first)]);
    		}
    	}
    }
   }

    cout << ans << endl;

	return 0;
}

Compilation message

pigus_skrydziai.cpp: In function 'int main()':
pigus_skrydziai.cpp:28:11: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |      scanf("%d%d%d", &x, &y, &z);
      |      ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 13 ms 23764 KB Output is correct
3 Correct 12 ms 23764 KB Output is correct
4 Correct 12 ms 23752 KB Output is correct
5 Correct 12 ms 23764 KB Output is correct
6 Correct 521 ms 26660 KB Output is correct
7 Correct 15 ms 23764 KB Output is correct
8 Correct 15 ms 23776 KB Output is correct
9 Correct 13 ms 23764 KB Output is correct
10 Correct 12 ms 23764 KB Output is correct
11 Correct 13 ms 23892 KB Output is correct
12 Correct 12 ms 23796 KB Output is correct
13 Correct 14 ms 23804 KB Output is correct
14 Correct 12 ms 23764 KB Output is correct
15 Correct 12 ms 23764 KB Output is correct
16 Correct 14 ms 23764 KB Output is correct
17 Correct 12 ms 23708 KB Output is correct
18 Correct 14 ms 23924 KB Output is correct
19 Correct 19 ms 24104 KB Output is correct
20 Correct 14 ms 23764 KB Output is correct
21 Correct 12 ms 23764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 13 ms 23764 KB Output is correct
3 Correct 12 ms 23764 KB Output is correct
4 Correct 12 ms 23752 KB Output is correct
5 Correct 12 ms 23764 KB Output is correct
6 Correct 521 ms 26660 KB Output is correct
7 Correct 15 ms 23764 KB Output is correct
8 Correct 15 ms 23776 KB Output is correct
9 Correct 13 ms 23764 KB Output is correct
10 Correct 12 ms 23764 KB Output is correct
11 Correct 13 ms 23892 KB Output is correct
12 Correct 12 ms 23796 KB Output is correct
13 Correct 14 ms 23804 KB Output is correct
14 Correct 12 ms 23764 KB Output is correct
15 Correct 12 ms 23764 KB Output is correct
16 Correct 14 ms 23764 KB Output is correct
17 Correct 12 ms 23708 KB Output is correct
18 Correct 14 ms 23924 KB Output is correct
19 Correct 19 ms 24104 KB Output is correct
20 Correct 14 ms 23764 KB Output is correct
21 Correct 12 ms 23764 KB Output is correct
22 Execution timed out 3063 ms 96956 KB Time limit exceeded
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 250 ms 54288 KB Output is correct
2 Correct 571 ms 73004 KB Output is correct
3 Incorrect 118 ms 40104 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 250 ms 54288 KB Output is correct
2 Correct 571 ms 73004 KB Output is correct
3 Incorrect 118 ms 40104 KB Output isn't correct
4 Halted 0 ms 0 KB -