結果
問題 | No.1708 Quality of Contest |
ユーザー |
![]() |
提出日時 | 2020-09-14 23:53:30 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 394 ms / 2,000 ms |
コード長 | 672 bytes |
コンパイル時間 | 2,581 ms |
コンパイル使用メモリ | 202,972 KB |
最終ジャッジ日時 | 2025-01-14 14:51:44 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0; i<(int)(n); i++) using namespace std; using LL = long long; int main(){ int N, M; LL X; cin >> N >> M >> X; vector<vector<LL>> G(M); rep(i,N){ LL v, g; cin >> v >> g; g--; G[g].emplace_back(v); } int K; cin >> K; vector<int> p(K); rep(i,K) cin >> p[i]; rep(i,M) sort(G[i].begin(),G[i].end(),greater<LL>()); rep(i,M) if(G[i].size()) G[i][0] += X; vector<LL> V; rep(i,M){ rep(j,G[i].size()) V.emplace_back(G[i][j]); } sort(V.begin(),V.end(),greater<LL>()); vector<LL> sum(N+1); rep(i,N) sum[i+1] = sum[i] + V[i]; LL ans = 0; rep(i,K) ans += sum[p[i]]; cout << ans << endl; return 0; }