SGU 165 解题报告
《SGU 165 解题报告》 by 朱晨光
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #include <cstdio> #include <algorithm> using namespace std; struct player { int id; float diff; }; bool operator <(const player &a,const player &b) { return a.diff<b.diff; } int main() { player players[6000]; int n; scanf("%d",&n); for (int i=0;i<n;++i) { float height; scanf("%f",&height); players[i].id=i+1; players[i].diff=height-2; } sort(players,players+n); printf("yes\n"); float s=0; for (int p=0,q=n-1;p<=q;) if (s>=0) { printf("%d ",players[p].id); s+=players[p++].diff; } else { printf("%d ",players[q].id); s+=players[q--].diff; } printf("\n"); } |

3 Responses
话说博主哪儿找的解题报告,我在网上搜不到啊,
可否给我发一些好的资料?
我要准备NOI
谢了
Reply
http://d.ream.at/pack-of-data-structures-and-algorithms/
http://d.ream.at/mirror-of-algorithm126com/
Reply
really thanks
Reply