結果
| 問題 | 
                            No.90 品物の並び替え
                             | 
                    
| コンテスト | |
| ユーザー | 
                             🍡yurahuna
                         | 
                    
| 提出日時 | 2016-05-18 11:26:44 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 13 ms / 5,000 ms | 
| コード長 | 932 bytes | 
| コンパイル時間 | 1,669 ms | 
| コンパイル使用メモリ | 172,436 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-11 01:01:49 | 
| 合計ジャッジ時間 | 2,242 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 9 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int N, M;
    cin >> N >> M;
    vector<vector<int>> a(N, vector<int>(N, 0));
    rep(i, M) {
        int x, y, z;
        cin >> x >> y >> z;
        a[x][y] = z;
    }
    vector<int> perm(N);
    iota(all(perm), 0);
    int ans = 0;
    do {
        int t = 0;
        rep(i, N) {
            rep2(j, i + 1, N) {
                t += a[perm[i]][perm[j]];
            }
        }
        ans = max(ans, t);
    } while( next_permutation(all(perm)) );
    cout << ans << endl;
}
            
            
            
        
            
🍡yurahuna