結果
問題 | No.90 品物の並び替え |
ユーザー |
|
提出日時 | 2023-04-30 20:55:34 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 111 ms / 5,000 ms |
コード長 | 940 bytes |
コンパイル時間 | 1,546 ms |
コンパイル使用メモリ | 169,404 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-19 10:35:19 |
合計ジャッジ時間 | 2,258 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define rep(i, n) for (int i = 0; i < (int)(n); i++)#define srep(i, s, n) for (int i=(s); i < (int)(n); i++)#define all(v) v.begin(), v.end()#define fore(i,x) for(auto i:x)#define pb push_backusing vi=vector<int>;using vvi=vector<vi>;using vb=vector<bool>;using vvb=vector<vb>;using vs=vector<string>;using vll=vector<long long>;using vvll=vector<vll>;using vc=vector<char>;using vvc=vector<vc>;using ll=long long;void Yes(bool ok){ cout << (ok ? "Yes" : "No") << "\n";}int main(){int N,M; cin >> N >> M;vi item1(M),item2(M),score(M);rep(i,M) cin >> item1.at(i) >> item2.at(i) >> score.at(i);vi v(N);rep(i,N) v.at(i)=i;int ans=0;do{int tmp=0;rep(i,M){if(v.at(item1.at(i))<v.at(item2.at(i))) tmp+=score.at(i);}ans=max(ans,tmp);}while(next_permutation(all(v)));cout << ans << "\n";}