标签:
1 #include "iostream" 2 #include "cstdio" 3 #include "cstring" 4 #include "algorithm" 5 #include "vector" 6 using namespace std; 7 int n, m; 8 int score[110]; 9 int tot, b[110]; 10 11 int main() 12 { 13 __int64 res = 0; 14 int i, j; 15 scanf("%d%d", &n, &m); 16 for(i = 1; i <= n; i++) { 17 scanf("%d", &score[i]); 18 res += score[i]; 19 } 20 tot = 0; 21 int index; 22 for(i = 1; i <= m; i++) { 23 scanf("%d", &index); 24 res -= score[index]; 25 b[++tot] = score[index]; 26 } 27 sort(b + 1, b + m + 1); 28 for(i = m; i >= 1; i--) { 29 if(res > b[i]) 30 res <<= 1; 31 else 32 res += b[i]; 33 34 } 35 printf("%I64d\n", res); 36 }
标签:
原文地址:http://www.cnblogs.com/AC-Phoenix/p/4298847.html