結果

問題 No.2623 Room Allocation
ユーザー 唐揚げが壊わ唐揚げが壊わ
提出日時 2024-02-09 23:04:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,871 bytes
コンパイル時間 1,717 ms
コンパイル使用メモリ 176,756 KB
実行使用メモリ 37,672 KB
最終ジャッジ日時 2024-02-09 23:05:02
合計ジャッジ時間 5,447 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 82 ms
26,040 KB
testcase_07 AC 79 ms
26,040 KB
testcase_08 AC 81 ms
26,040 KB
testcase_09 AC 81 ms
26,040 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 2 ms
6,676 KB
testcase_13 RE -
testcase_14 WA -
testcase_15 AC 111 ms
14,264 KB
testcase_16 AC 28 ms
6,676 KB
testcase_17 AC 3 ms
6,676 KB
testcase_18 AC 113 ms
14,264 KB
testcase_19 AC 106 ms
13,556 KB
testcase_20 AC 112 ms
14,068 KB
testcase_21 AC 113 ms
14,264 KB
testcase_22 AC 86 ms
11,512 KB
testcase_23 AC 50 ms
7,936 KB
testcase_24 AC 113 ms
14,264 KB
testcase_25 AC 90 ms
12,284 KB
testcase_26 AC 10 ms
6,676 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vvvll = vector<vector<vector<long long>>>;
using vvvvll = vector<vector<vector<vector<long long>>>>;
using vpll = vector<pair<ll, ll>>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using pll = pair<ll, ll>;
#define REP(i, n) for (long long i = 0; i < n; i++)
#define REP2(i, n, m) for (long long i = n; i < m; i++)
#define REPv(v) for (auto itr = v.begin(); itr != v.end(); itr++)
#define REPIN(v) \
  for (long long i = 0; i < (long long)v.size(); i++) cin >> v[i];
#define been(vec) vec.begin(), vec.end()
#define LIN      \
  = []() {       \
    long long x; \
    cin >> x;    \
    return x;    \
  }()
#define SIN   \
  = []() {    \
    string x; \
    cin >> x; \
    return x; \
  }()
#define SPNL(i, SIZE) (i + 1 == SIZE ? '\n' : ' ')
ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
bool chmin(ll &a, const ll &b) { return (a > b && ((a = b) | 1)); }
bool chmax(ll &a, const ll &b) { return (a < b && ((a = b) | 1)); }

using namespace std;
int main() {
  ll n LIN, x LIN, y LIN;
  ll nd = min(x + y, n);
  vvll pc(n, {0, 0});
  REP(i, n) {
    char tmp;
    cin >> pc[i][0] >> tmp;
    pc[i][1] = tmp;
  }
  // (x+y)k
  ll roomA = 0;
  vvll ide(nd, vll(2, 0));
  vll d(nd);
  REP(i, nd) {
    for (ll j = 0; i + j * (x + y) < n; j++) {
      ll I = i + j * (x + y);
      if (pc[I][1] == ll('A'))
        ide[i][0] += pc[I][0];
      else
        ide[i][1] += pc[I][0];
    }
    d[i] = ide[i][1] - ide[i][0];
    roomA += ide[i][0];
  }

  vvll dp(nd + 1, vll(2, 0));
  sort(been(d), [](ll a, ll b) { return a > b; });
  REP(i, y) { roomA += d[i]; }
  cout << roomA << endl;
  return 0;
}
0