记录编号 84554 评测结果 AAAAAAAAAA
题目名称 [HAOI 2009]巧克力 最终得分 100
用户昵称 Gravatar超级傲娇的AC酱 是否通过 通过
代码语言 C++ 运行时间 0.008 s
提交时间 2013-12-15 12:19:40 内存使用 0.34 MiB
显示代码纯文本
  1. #include<fstream>
  2. #include<algorithm>
  3. using namespace std;
  4. ifstream fi("chocolate.in");
  5. ofstream fo("chocolate.out");
  6. bool cmp(int x,int y){
  7. return x>y;
  8. }
  9. int main()
  10. {
  11. int n,m,i,j,X[20010],Y[20010],posx=1,posy=1,Ans=0;
  12. fi>>n>>m;
  13. for(i=1;i<n;i++)fi>>Y[i];
  14. for(j=1;j<m;j++)fi>>X[j];
  15. sort(X+1,X+m,cmp);sort(Y+1,Y+n,cmp);
  16. for(i=0;i<m+n-2;i++)
  17. {
  18. if(X[posx]>Y[posy])
  19. Ans+=posy*X[posx],posx++;
  20. else
  21. Ans+=posx*Y[posy],posy++;
  22. }
  23. fo<<Ans;
  24. return 0;
  25. }