竞赛讨论区 > 为什么超时???
头像
~ing
发布于 2018-10-13 01:35
+ 关注

为什么超时???

为什么超时???
#include "bits/stdc++.h"

using namespace std;

int main()
{
    int n,m,k;
    cin>>n>>m>>k;
     vector<priority_queue<int> > vec;
    for(int i=0;i<=n-1;i++)
    {
        priority_queue <int> que;
        for(int j=0;j<=m-1;j++)
        {
            int x;
            cin>>x;
            que.push(x);
        }
        vec.push_back(que);
     } 
     int ans=0;
     while(k--)
     {
         int pos=0,first=0x3f3f3f3f;
         for(int i=0;i<=n-1;i++)
         {
             
             if(!vec[i].empty()&&first>=vec[i].top())
             {
                 first=vec[i].top();
                 pos=i;
             }
            
         }
         ans+=first;
         vec[pos].pop();
    }
    cout<<ans<<endl;
    return 0;
}

全部评论

(1) 回帖
加载中...
话题 回帖

等你来战

查看全部

热门推荐