- 合并果子
- 2009-07-30 17:57:55 @
如题,为什么用stl库可以ac呢?!
2 条评论
-
NERvGear LV 8 @ 2016-03-12 16:05:23
编译成功
测试数据 #0: Accepted, time = 15 ms, mem = 704 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 552 KiB, score = 10
测试数据 #2: Accepted, time = 0 ms, mem = 556 KiB, score = 10
测试数据 #3: Accepted, time = 0 ms, mem = 556 KiB, score = 10
测试数据 #4: Accepted, time = 15 ms, mem = 592 KiB, score = 10
测试数据 #5: Accepted, time = 0 ms, mem = 636 KiB, score = 10
测试数据 #6: Accepted, time = 15 ms, mem = 704 KiB, score = 10
测试数据 #7: Accepted, time = 15 ms, mem = 704 KiB, score = 10
测试数据 #8: Accepted, time = 15 ms, mem = 704 KiB, score = 10
测试数据 #9: Accepted, time = 15 ms, mem = 700 KiB, score = 10
Accepted, time = 90 ms, mem = 704 KiB, score = 100
#include <iostream>
#include <queue>
using namespace std;
int main(){priority_queue<int,vector<int>,greater<int> > Q;
int n,k,i;
cin>>n;
for(i=0;i<n;i++){
cin>>k;
Q.push(k);
}
int js=0;
for(i=0;i<n-1;i++){
int a=Q.top();
Q.pop();
int b=Q.top();
Q.pop();
js+=a+b;
Q.push(a+b);
}
cout<<js<<endl;
system("pause");
return 0;
} -
2013-08-05 17:43:31@
早就开放了哦~~
- 1