結果

問題 No.1430 Coup de Coupon
ユーザー umezoumezo
提出日時 2021-03-14 15:45:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 863 bytes
コンパイル時間 2,399 ms
コンパイル使用メモリ 203,476 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-23 23:16:25
合計ジャッジ時間 2,996 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 3 ms
6,940 KB
testcase_04 AC 4 ms
6,940 KB
testcase_05 AC 3 ms
6,940 KB
testcase_06 AC 6 ms
6,944 KB
testcase_07 AC 6 ms
6,940 KB
testcase_08 AC 5 ms
6,940 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 5 ms
6,944 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 2 ms
6,944 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;

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

int main(){
  int n,c;
  cin>>n>>c;
  vector<int> P(n);
  rep(i,n) cin>>P[i];
  sort(ALL(P));
  reverse(ALL(P));
  priority_queue<int> q1,q2;
  rep(i,c){
    int t,x;
    cin>>t>>x;
    if(t==1) q1.push(x);
    else q2.push(x);
  }
  int ans=0;
  rep(i,n){
    if(q1.size()>0 && q2.size()>0){
      if(max(P[i]-q1.top(),0)<=P[i]/100*(100-q2.top())){
        ans+=max(P[i]-q1.top(),0);
        q1.pop();
      }
      else{
        ans+=P[i]/100*(100-q2.top());
        q2.pop();
      }
    }
    else if(q1.size()>0){
      ans+=max(P[i]-q1.top(),0);
      q1.pop();
    }
    else if(q2.size()>0){
      ans+=P[i]/100*(100-q2.top());
      q2.pop();
    }
    else ans+=P[i];
  }
  cout<<ans<<endl;

  return 0;
}
0