結果

問題 No.472 平均順位
ユーザー darisdaris
提出日時 2022-03-25 13:07:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 2,098 bytes
コンパイル時間 2,501 ms
コンパイル使用メモリ 198,980 KB
実行使用メモリ 296,832 KB
最終ジャッジ日時 2024-04-21 21:42:22
合計ジャッジ時間 5,851 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 3 ms
6,940 KB
testcase_08 AC 7 ms
6,940 KB
testcase_09 AC 23 ms
11,392 KB
testcase_10 AC 16 ms
8,448 KB
testcase_11 AC 69 ms
28,160 KB
testcase_12 AC 48 ms
20,736 KB
testcase_13 AC 177 ms
68,608 KB
testcase_14 AC 594 ms
244,096 KB
testcase_15 AC 175 ms
68,608 KB
testcase_16 MLE -
testcase_17 MLE -
testcase_18 AC 45 ms
20,608 KB
testcase_19 AC 83 ms
34,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#if !__INCLUDE_LEVEL__

#include __FILE__



int main() {
  int n, p;
  input(n, p);
  VVI dp(n + 1, VI(p + 1, INT_MAX));
  dp[0][0] = 0;
  rep(i, 0, n) {
    VI d(4, 1);
    rep(i, 0, 3) input(d[i]);
    rep(k, 0, 4) {
      rep(j, 0, p + 1) {
        if(j + k <= p && dp[i][j] != INT_MAX) {
          chmin(dp[i + 1][j + k], dp[i][j] + d[k]);
          //print(i + 1, j + k, dp[i + 1][j - k]); 
        }
      }
    }
  }
  cout << fixed << setprecision(5);
  print((double)dp[n][p] / (double)n);
  return 0;
}
/*
平均順位の出し方
 最後にNで割れば良い
ナップザック
 dp[i][j] : コストがjを超えないように選ぶ
 コストの和をpにしなければならない
*/

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

#define _GLIBCXX_DEBUG 
#define rep(i, j, n) for(int i = j; i < n; i++)
#define rrep(i, j, n) for(int i = n - 1; j <= i; i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define MOD1 = 998244353;
#define MOD2 = 1000000007;

using LL = long long;
using VI = vector<int>;
using VS = vector<string>;
using VLL = vector<LL>;
using VC = vector<char>;
using VD = vector<double>;
using VB = vector<bool>;
using PII = pair<int, int>;
using PSS = pair<string, string>;
using PIS = pair<int , string>;
using PSI = pair<string, int>;
using PLL = pair<LL, LL>;
using PCC = pair<char, char>;
using VVI = vector<VI>;
using VVS = vector<VS>;
using VVLL = vector<VLL>;
using VVC = vector<VC>;
using VVD = vector<VD>;
using VPII = vector<PII>;
using VPSS = vector<PSS>;
using VPIS = vector<PIS>;
using VPSI = vector<PSI>;
using VPLL = vector<PLL>;

template<typename T> bool chmax(T& a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T &b) { if (a > b) { a = b; return true; } return false; }
template<class... T> void input(T&... a) { (cin >> ... >> a); }
template<class T> void print (const T &a) { cout << a << '\n'; }
template<class T, class... Ts> void print(const T& a, const Ts&... b) { cout << a; (cout << ... << (cout << ' ', b)); cout << '\n'; }



#endif
0