标签:
Crawling in process... Crawling failed Time Limit:3000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u
Description
Input
Output
Sample Input
Sample Output
1 #include "iostream" 2 #include "algorithm" 3 4 using namespace std; 5 struct enemy 6 { 7 int hp; 8 int dp; 9 }; 10 enemy N[21]; 11 enemy T[21]; 12 int sum; 13 __int64 dead; 14 void ebegin(int n) 15 { 16 for (int i=1;i<=n;i++) 17 { 18 cin>>N[i].dp>>N[i].hp; 19 sum += N[i].dp; 20 } 21 } 22 void defeat (int n) 23 { 24 for (int i=1;i<=n;i++) 25 { 26 dead += sum * N[i].hp; 27 sum -= N[i].dp; 28 } 29 cout<<dead<<endl; 30 } 31 int compare (enemy x,enemy y) 32 { 33 return x.hp * y.dp < x.dp * y.hp; 34 } 35 int main() 36 { 37 int n; 38 while (cin>>n) 39 { 40 dead = 0; 41 ebegin(n); 42 sort(N+1,N+n+1,compare); 43 defeat(n); 44 } 45 return 0; 46 }
暑假集训(2)第八弹 ----- Hero(hdu4310)
标签:
原文地址:http://www.cnblogs.com/huas-zlw/p/5697089.html