結果
| 問題 | No.3751 Nonopoly |
| コンテスト | |
| ユーザー |
yaaya
|
| 提出日時 | 2026-10-04 04:18:54 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 49 ms / 2,000 ms |
| + 620µs | |
| コード長 | 1,540 bytes |
| 記録 | |
| コンパイル時間 | 3,745 ms |
| コンパイル使用メモリ | 342,108 KB |
| 実行使用メモリ | 9,912 KB |
| 最終ジャッジ日時 | 2026-10-04 04:19:20 |
| 合計ジャッジ時間 | 9,773 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 50 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)
#define ll long long
#define ull unsigned ll
#define ld long double
#define bl __int128_t
#define fi first
#define se second
#define vel vector<ll>
#define vvel vector<vel>
#define pll pair<ll,ll>
#define vepll vector<pll>
#define vvepll vector<vepll>
#define ves vector<string>
#define vem vector<mint>
#define vvem vector<vem>
#define pmm pair<mint,mint>
#define cleout(i) cout<<fixed<<setprecision(i)
template<class T>using PQ=priority_queue<T,vector<T>,greater<T>>;
// 上 右 下 左
vector<int> di={-1, 0, 1, 0};
vector<int> dj={ 0, 1, 0,-1};
vector<int> dx={ 0, 1, 0,-1};
vector<int> dy={ 1, 0,-1, 0};
vector<int> ddx={ 1, 1, 1, 0, -1, -1, -1, 0 };
vector<int> ddy={ 1, 0, -1, -1, -1, 0, 1, 1 };
ll inf=1000000000000000000;//1e18
// LLONG_MAX
mt19937_64 rng((ull)chrono::steady_clock::now().time_since_epoch().count());
void _solve(){
ll N,M;
cin>>N>>M;
priority_queue<ll> pq;
vel a(N);
rep(i,0,M){
ll x,y,z;
cin>>x>>y>>z;
x--;
y--;
a[x]+=z;
a[y]+=z;
}
rep(i,0,N)pq.push(a[i]);
ll ans=0;
rep(i,0,N){
if(i%2)ans-=pq.top();
else ans+=pq.top();
pq.pop();
}
cout<<ans/2<<"\n";
}
int main(){
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
ll _;
bool multitest=0;
if(multitest)cin>>_;
else _=1;
rep(__,0,_){
_solve();
}
}
yaaya