zoukankan      html  css  js  c++  java
  • bug

    #include<bits/stdc++.h>
    #define FOR(i,f_start,f_end) for(int i=f_start;i<=f_end;i++)
    #define MS(arr,arr_value) memset(arr,arr_value,sizeof(arr))
    #define F first
    #define S second
    #define pii pair<int ,int >
    #define mkp make_pair
    #define pb push_back
    using namespace std;
    const int maxn=5000+5;
    struct cmp{
        bool operator()(const pii p1,const pii p2){
            return p1.F>p2.F;
        }

    };
    priority_queue<pii,vector<pii> ,cmp>q;
    queue<pii>s;
    int a[maxn];
    int main(){
        int n,k;
        scanf("%d%d",&n,&k);
        FOR(i,1,n)scanf("%d",&a[i]);
        int now=0;
        int ok=0;
        int p=1;
        int ans=0;
        int que[1005];
        int last=0;
        for(;;){
            if(q.empty()&&p>n)break;
            while(q.size()<k&&p<=n){
                q.push(mkp(now+a[p],p));
                    p++;
                    
            }
            pii v=q.top();
            s.push(v);
            q.pop();
            int tmp=0;
            ok++;
            tmp++;
            while(!q.empty()&&q.top().F==v.F){
                s.push(q.top());
                q.pop();
                ok++;
                tmp++;
            }
            int d1=(100.0*ok/n+0.5);
            while(!s.empty()){
                pii u=s.front();
                s.pop();
             cout<<a[u.S]<<" "<<d1<<" "<<last<<endl;
                if(a[u.S]>=last&&last!=0)ans++;
            }
            last=d1;
            now=v.F;    
        }
        cout<<ans<<endl;
        return 0;

    }

  • 相关阅读:
    配合网页滚屏播放,做解说词
    @enable跟@import注解
    组合注解与元注解
    Spring Aware
    https的设计原理
    用信鸽来解释 HTTPS
    http三次握手四次挥手
    一致性哈希
    redis cluster原理
    redis cluster集群搭建
  • 原文地址:https://www.cnblogs.com/ttttttttrx/p/10554167.html
Copyright © 2011-2022 走看看