結果
問題 | No.90 品物の並び替え |
ユーザー |
|
提出日時 | 2019-04-12 17:06:48 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 98 ms / 5,000 ms |
コード長 | 1,539 bytes |
コンパイル時間 | 792 ms |
コンパイル使用メモリ | 89,592 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-14 07:01:55 |
合計ジャッジ時間 | 1,458 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
コンパイルメッセージ
main.cpp: In function ‘int main(int, char**)’: main.cpp:58:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 58 | REP(i, m) scanf("%d%d%d", &x[i].i1, &x[i].i2, &x[i].score); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <assert.h>#include <ctype.h>#include <float.h>#include <limits.h>#include <math.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/types.h>#include <algorithm>#include <bitset>#include <complex>#include <iostream>#include <list>#include <map>#include <numeric>#include <queue>#include <set>#include <sstream>#include <stack>#include <string>#include <unordered_map>#include <unordered_set>#include <vector>using namespace std;#define SZ(a) (int)(a).size()#define FOR(i,a,b) for (int i=(a); i<=(b); ++i)#define REP(i,n) for (int i=0; i<(n); ++i)#define ALL(c) c.begin(), c.end()#define CLR(c,n) memset(c, n, sizeof(c))#define MCPY(d, s) memcpy(d, s, sizeof(d))#define TR(it, c) for (auto it = c.begin();it != c.end(); ++it)#define CONTAIN(it, c) (c.find(it) != c.end())typedef vector<int> VI;typedef pair<int, int> PII;template <class T> void checkmin(T &a, T b) { if (b<a) a=b; }template <class T> void checkmax(T &a, T b) { if (b>a) a=b; }typedef long long LL;const int INF=0x3F3F3F3F;const int N=9, M=72;int n, m;struct Item {int i1, i2, score;} x[M];int go(int *f) {int ans = 0;REP(i, m) if (f[x[i].i1] < f[x[i].i2]) ans += x[i].score;return ans;}int main(int argc, char *argv[]) {while (scanf("%d%d", &n, &m) == 2) {REP(i, m) scanf("%d%d%d", &x[i].i1, &x[i].i2, &x[i].score);int f[N], best = 0;REP(i, n) f[i] = i;do {checkmax(best, go(f));} while (next_permutation(f, f+n));cout << best << endl;}}