結果

問題 No.3751 Nonopoly
コンテスト
ユーザー marc2825
提出日時 2026-08-08 18:57:39
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 628 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,143 ms
コンパイル使用メモリ 221,788 KB
実行使用メモリ 9,920 KB
最終ジャッジ日時 2026-10-02 20:54:12
合計ジャッジ時間 4,698 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 2
other AC * 5 WA * 45
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int N, M;
    cin >> N >> M;
    
    vector<tuple<long long,int,int>> edges(M);
    for(auto& [w,u,v] : edges){
        cin >> u >> v >> w;
    }
    
    // Sort edges by weight descending
    sort(edges.begin(), edges.end(), greater<>());
    
    long long score = 0;
    for(int i = 0; i < M; i++){
        auto [w,u,v] = edges[i];
        if(i % 2 == 0) score += w;  // Alice's turn -> +W
        else score -= w;             // Bob's turn -> -W
    }
    
    cout << score << "\n";
    return 0;
}
0