zoukankan      html  css  js  c++  java
  • CF1121C 模拟

    恶心场恶心题,,round千万不能用库函数的。。

    /*枚举时间轴t,r是当前完成比例,
    记录每个测试的开始时间si,如果有t-si等于r,那么这个测试就标记一下
    优先队列存储每个测试,按照si+ai的顺序升序排列,一旦完成就出队,更新测试率,加入新元素即可 
    */
    #include<bits/stdc++.h>
    #include<queue>
    using namespace std;
    struct node{
        int s,a;
    }p[1050];
    priority_queue<node> q;
    bool operator<(const node & x,const node &y){
        return x.s+x.a>y.s+y.a;
    }
    int n,k,t,r[1000*150];
    int main(){
        cin>>n>>k;
        for(int i=1;i<=n;i++)
            cin>>p[i].a;
        int id=0,f=0;
        while(q.size()<k){
            if(id==n)break;
            p[++id].s=0;
            q.push(p[id]);
        }
        for(t=0;t<=1000*150;t++){
            while(!q.empty()){
                node tmp=q.top();
                if(tmp.a+tmp.s==t){
                    q.pop();
                    f++;
    //cout<<round(100*f/n)<<endl;
                }
                else break;
            }
            while(q.size()<k){
                if(id==n)break;
                p[++id].s=t;
                q.push(p[id]);
            }
            r[t]=100.0*f/n+0.5;
        }
        
        int ans=0;
        for(int i=1;i<=n;i++){
            for(int j=p[i].s;j<p[i].s+p[i].a;j++)
                if(r[j]==j-p[i].s+1){
                    ans++;break;
                }
        }
        cout<<ans<<endl;
    return 0;
    } 
  • 相关阅读:
    HttpModule和HttpHandler
    SharePoint
    两种遍历Hashtable方法(小技巧)
    在线游戏开发人员的行话
    AS3 条件编译
    Flash开发MMORPG的时候一些技术障碍
    Java实现几种常见排序方法
    画贝塞尔曲线
    一一解答
    如何留住核心人才?
  • 原文地址:https://www.cnblogs.com/zsben991126/p/10469830.html
Copyright © 2011-2022 走看看