记录编号 | 187727 | 评测结果 | AAAAAAAAAA | ||
---|---|---|---|---|---|
题目名称 | [USACO Mar]提高速度 | 最终得分 | 100 | ||
用户昵称 | 是否通过 | 通过 | |||
代码语言 | C++ | 运行时间 | 0.026 s | ||
提交时间 | 2015-09-20 16:31:42 | 内存使用 | 0.53 MiB | ||
#include<cstdio> #include<iostream> #include<algorithm> using namespace std; const double esp=1e-7; int F,M,N; int f[10011],m[10010]; bool ch[10010]={0}; class miku { public: double F,M; int pos; }P[10010]; bool cmp(miku a,miku b) { return a.F/a.M>b.F/b.M; } void read() { scanf("%lf%lf%d",&P[0].F,&P[0].M,&N); for(int i=1;i<=N;i++) { scanf("%lf%lf",&P[i].F,&P[i].M); P[i].pos=i; } sort(P+1,P+1+N,cmp); } void work() { //for(int i=1;i<=N;i++) // cout<<P[i].pos<<" "<<P[i].F<<" "<<P[i].M<<endl; for(int i=1;i<=N;i++) { if((P[0].F+P[i].F)/(P[0].M+P[i].M)>P[0].F/P[0].M) { P[0].F+=P[i].F; P[0].M+=P[i].M; ch[P[i].pos]=1; } } bool flag=0; for(int i=1;i<=N;i++) { if(ch[i]==1) { flag=1; printf("%d\n",i); } } if(flag==0)printf("NONE\n"); } int main() { freopen("sboost.in","r",stdin); freopen("sboost.out","w",stdout); read(); work(); return 0; }