結果
問題 | No.1708 Quality of Contest |
ユーザー |
|
提出日時 | 2021-10-15 22:15:48 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 114 ms / 2,000 ms |
コード長 | 1,678 bytes |
コンパイル時間 | 1,751 ms |
コンパイル使用メモリ | 178,200 KB |
実行使用メモリ | 18,260 KB |
最終ジャッジ日時 | 2024-09-17 17:37:09 |
合計ジャッジ時間 | 4,916 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#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;}