結果
| 問題 | No.3751 Nonopoly |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-31 14:51:56 |
| 言語 | C++23(gcc16) (gcc 16.2.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 43 ms / 2,000 ms |
| + 945µs | |
| コード長 | 528 bytes |
| 記録 | |
| コンパイル時間 | 1,504 ms |
| コンパイル使用メモリ | 185,536 KB |
| 実行使用メモリ | 9,904 KB |
| 最終ジャッジ日時 | 2026-10-31 14:52:40 |
| 合計ジャッジ時間 | 11,192 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge7_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 50 |
ソースコード
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N, M; cin>>N>>M;
vector<ll> com(N+1, 0);
for (int i=0;i<M;i++){
int U, V; ll W; cin>>U>>V>>W;
com[U]+=W;
com[V]+=W;
}
sort(&com[1], &com[N+1], greater<ll>());
ll a=0, b=0;
for (int i=1;i<=N;i++){
if (i%2==1) a+=com[i];
else b+=com[i];
}
cout << (a-b)/2 << "\n";
return 0;
}