結果

問題 No.1708 Quality of Contest
ユーザー uytvccuytvcc
提出日時 2021-10-15 22:15:48
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 113 ms / 2,000 ms
コード長 1,678 bytes
コンパイル時間 2,437 ms
コンパイル使用メモリ 179,052 KB
実行使用メモリ 18,364 KB
最終ジャッジ日時 2023-10-17 20:24:59
合計ジャッジ時間 5,031 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 3 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 3 ms
4,348 KB
testcase_04 AC 4 ms
4,348 KB
testcase_05 AC 4 ms
4,348 KB
testcase_06 AC 4 ms
4,348 KB
testcase_07 AC 4 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 103 ms
18,364 KB
testcase_10 AC 85 ms
12,900 KB
testcase_11 AC 98 ms
10,980 KB
testcase_12 AC 99 ms
11,984 KB
testcase_13 AC 94 ms
10,120 KB
testcase_14 AC 101 ms
12,564 KB
testcase_15 AC 113 ms
16,080 KB
testcase_16 AC 113 ms
15,744 KB
testcase_17 AC 101 ms
13,012 KB
testcase_18 AC 101 ms
13,304 KB
testcase_19 AC 102 ms
14,312 KB
testcase_20 AC 98 ms
12,828 KB
testcase_21 AC 107 ms
13,648 KB
testcase_22 AC 105 ms
12,640 KB
testcase_23 AC 112 ms
15,856 KB
testcase_24 AC 84 ms
8,712 KB
testcase_25 AC 85 ms
8,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF 1000000007
#define LINF 1000000000000000007LL
#define PI 3.14159265359
#define P pair<ll,ll>
template <typename T>
inline bool chmax(T &a, const T &b){
  if(a<b) {a=b; return true;}
  else return false;
}
template <typename T>
inline bool chmin(T &a, const T &b){
  if(a>b) {a=b; return true;}
  else return false;
}
struct Edge{
  int to; ll cost;
  Edge(int to, ll cost) : to(to), cost(cost) {}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g,int from,int to,ll cost,bool rev,ll rev_cost){
  g[from].push_back(Edge(to,cost));
  if(rev) g[to].push_back(Edge(from,rev_cost));
}



void solve(){
  int n,m,x;
  cin>>n>>m>>x;
  vector<int> a(n),b(n);
  rep(i,n){
    cin>>a[i]>>b[i];
    b[i]--;
  }
  int k;
  cin>>k;
  vector<int> c(k);
  rep(i,k) cin>>c[i];
  //----------------------------------------
  vector<vector<int>> kind(m);
  rep(i,n){
    kind[b[i]].push_back(a[i]);
  }
  vector<int> points;
  rep(i,m){
    if(kind[i].size()){
      sort(kind[i].begin(),kind[i].end(),greater<int>());
      kind[i][0]+=x;
    }
    for(auto p : kind[i]) points.push_back(p);
  }
  sort(points.begin(),points.end(),greater<int>());
  vector<int> solved(n+1);
  solved[0]=k;
  rep(i,k) solved[c[i]+1]--;
  rep(i,n) solved[i+1]+=solved[i];
  ll ans=0;
  rep(i,n) ans += (ll)solved[i+1]*(ll)points[i];
  cout<<ans<<'\n';
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<setprecision(10)<<fixed;
  solve();
  return 0;
}
0