結果

問題 No.1708 Quality of Contest
ユーザー untiunti
提出日時 2021-10-15 23:25:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 1,293 bytes
コンパイル時間 2,036 ms
コンパイル使用メモリ 176,936 KB
実行使用メモリ 17,300 KB
最終ジャッジ日時 2023-10-17 21:09:34
合計ジャッジ時間 5,724 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 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 3 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 119 ms
17,300 KB
testcase_10 AC 86 ms
12,632 KB
testcase_11 AC 112 ms
10,928 KB
testcase_12 AC 121 ms
11,804 KB
testcase_13 AC 105 ms
10,132 KB
testcase_14 AC 122 ms
12,212 KB
testcase_15 AC 137 ms
15,276 KB
testcase_16 AC 135 ms
14,964 KB
testcase_17 AC 117 ms
12,672 KB
testcase_18 AC 120 ms
12,936 KB
testcase_19 AC 121 ms
13,832 KB
testcase_20 AC 115 ms
12,508 KB
testcase_21 AC 131 ms
13,056 KB
testcase_22 AC 124 ms
12,280 KB
testcase_23 AC 135 ms
15,068 KB
testcase_24 AC 88 ms
8,764 KB
testcase_25 AC 87 ms
8,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}



int main(){
  ios::sync_with_stdio(false) ;
  cin.tie(nullptr) ;
  
 ll n,m,x ; cin>>n>>m>>x ;
 Graph g(m) ;
 rep(i,n){
   ll z,y ; cin>>z>>y ;
   g[y-1].pb(z) ;
 }
 vector<ll> all ;
 rep(i,m){
   if(!g[i].size()) continue ;
   sort(g[i].rbegin(),g[i].rend()) ;
   g[i][0]+=x ;
   for(auto u:g[i]) all.pb(u) ;
 }
 
 sort(all.rbegin(),all.rend()) ;
 
 vector<ll> rui(n+1) ;
 rui[0]=0 ;
 rep(i,n) rui[i+1]=rui[i]+all[i] ;
 ll ans=0ll ;
 ll k ; cin>>k ;
 rep(i,k){ll t ; cin>>t ;ans+=rui[t] ;}
 cout<<ans<<endl ;

  return  0 ; 
}

0