結果

問題 No.1430 Coup de Coupon
ユーザー tnakao0123tnakao0123
提出日時 2021-03-15 00:40:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,229 bytes
コンパイル時間 988 ms
コンパイル使用メモリ 100,220 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 05:57:05
合計ジャッジ時間 2,088 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 4 ms
5,376 KB
testcase_08 AC 4 ms
5,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 3 ms
5,376 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 2 ms
5,376 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 1430.cc:  No.1430 Coup de Coupon - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 5000;
const int INF = 1 << 30;

/* typedef */

/* global variables */

int ps[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, c;
  scanf("%d%d", &n, &c);

  for (int i = 0; i < n; i++) scanf("%d", ps + i);
  sort(ps, ps + n);

  priority_queue<int> q1, q2;

  for (int i = 0; i < c; i++) {
    int t, x;
    scanf("%d%d", &t, &x);
    if (t == 1) q1.push(x);
    else q2.push(x);
  }

  int sum = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (q1.empty() && q2.empty())
      sum += ps[i];
    else {
      int p1 = INF, p2 = INF;
      if (! q1.empty()) p1 = max(ps[i] - q1.top(), 0);
      if (! q2.empty()) p2 = ps[i] / 100 * (100 - q2.top());
      if (p1 < p2) sum += p1, q1.pop();
      else sum += p2, q2.pop();
    }
  }

  printf("%d\n", sum);
  return 0;
}
0