結果
| 問題 |
No.90 品物の並び替え
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-06-30 05:54:37 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 21 ms / 5,000 ms |
| コード長 | 925 bytes |
| コンパイル時間 | 2,133 ms |
| コンパイル使用メモリ | 201,344 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-06-30 05:54:40 |
| 合計ジャッジ時間 | 2,906 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
template<typename T>
istream &operator>>(istream &is,vector<T> &a){
for(auto &v : a) cin >> v;
return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &a){
if(a.size() == 0) return os;
cout << a.at(0);
for(int i=1; i<a.size(); i++) cout << " " << a.at(i);
cout << "\n";
return os;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N,M; cin >> N >> M;
vector<vector<int>> S(N,vector<int>(N));
while(M--){
int a,b,s; cin >> a >> b >> s;
S.at(a).at(b) = s;
}
vector<int> P(N);
iota(P.begin(),P.end(),0);
int answer = 0;
do{
int now = 0;
for(int i=0; i<N; i++) for(int k=i+1; k<N; k++) now += S.at(P.at(i)).at(P.at(k));
answer = max(answer,now);
}while(next_permutation(P.begin(),P.end()));
cout << answer << endl;
}