Submission #893316

# Submission time Handle Problem Language Result Execution time Memory
893316 2023-12-27T01:22:32 Z vjudge1 Topical (NOI23_topical) C++17
100 / 100
448 ms 149696 KB
#include<bits/stdc++.h>
#define TASKNAME "codeforce"
#define pb push_back
#define pli pair<int,int>
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
using ll=long long;
const ll maxn=1e6+10;
const ll inf=1e18;
const ll mod=1e9+7;
ll n,k,s[maxn],id[maxn],cnt[maxn];
bool r[maxn];
vector<vector<pli>>c;
vector<vector<ll>>u;
void solve()
{
    cin >> n >> k;
    c.resize(k+2,vector<pli>(n+2));
    u.resize(k+2,vector<ll>(n+2));
    for(int j=1;j<=n;j++)
    {
        for(int i=1;i<=k;i++)
        {
            cin >> c[i][j].fi;
            c[i][j].se=j;
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            cin >> u[j][i];
        }
    }
    for(int i=1;i<=k;i++) sort(c[i].begin()+1,c[i].begin()+n+1);
    for(int i=1;i<=k;i++) s[i]=0,id[i]=1;
    priority_queue<pli>pq;
    for(int i=1;i<=n;i++) r[i]=false,cnt[i]=0,pq.push({cnt[i],i});
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            while(id[j]<=n&&c[j][id[j]].fi<=s[j])
            {
                cnt[c[j][id[j]].se]++;
                pq.push({cnt[c[j][id[j]].se],c[j][id[j]].se});
                id[j]++;
            }
        }
        while(pq.size()>0&&r[pq.top().se]==true) pq.pop();
        if(pq.size()==0||pq.top().fi<k)
        {
            break;
        }
        ll id=pq.top().se;
        pq.pop();
        for(int j=1;j<=k;j++)
        {
            s[j]+=u[j][id];
        }
        ans=i;
    }
    cout << ans;
}
int main()
{
    fastio
    //freopen("c.INP","r",stdin);
    //freopen("c.OUT","w",stdout);
    solve();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6488 KB Output is correct
3 Correct 4 ms 7832 KB Output is correct
4 Correct 249 ms 149320 KB Output is correct
5 Correct 243 ms 149696 KB Output is correct
6 Correct 231 ms 149184 KB Output is correct
7 Correct 171 ms 133852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 2 ms 6488 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 3 ms 7004 KB Output is correct
8 Correct 3 ms 7004 KB Output is correct
9 Correct 3 ms 7004 KB Output is correct
10 Correct 3 ms 7004 KB Output is correct
11 Correct 3 ms 7004 KB Output is correct
12 Correct 3 ms 7000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 5 ms 7256 KB Output is correct
4 Correct 36 ms 15036 KB Output is correct
5 Correct 30 ms 14652 KB Output is correct
6 Correct 446 ms 104512 KB Output is correct
7 Correct 386 ms 93384 KB Output is correct
8 Correct 448 ms 103908 KB Output is correct
9 Correct 364 ms 92952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6488 KB Output is correct
3 Correct 4 ms 7832 KB Output is correct
4 Correct 249 ms 149320 KB Output is correct
5 Correct 243 ms 149696 KB Output is correct
6 Correct 231 ms 149184 KB Output is correct
7 Correct 171 ms 133852 KB Output is correct
8 Correct 1 ms 6488 KB Output is correct
9 Correct 2 ms 6488 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 1 ms 6492 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 3 ms 7004 KB Output is correct
15 Correct 3 ms 7004 KB Output is correct
16 Correct 3 ms 7004 KB Output is correct
17 Correct 3 ms 7004 KB Output is correct
18 Correct 3 ms 7004 KB Output is correct
19 Correct 3 ms 7000 KB Output is correct
20 Correct 1 ms 6492 KB Output is correct
21 Correct 1 ms 6492 KB Output is correct
22 Correct 5 ms 7256 KB Output is correct
23 Correct 36 ms 15036 KB Output is correct
24 Correct 30 ms 14652 KB Output is correct
25 Correct 446 ms 104512 KB Output is correct
26 Correct 386 ms 93384 KB Output is correct
27 Correct 448 ms 103908 KB Output is correct
28 Correct 364 ms 92952 KB Output is correct
29 Correct 216 ms 50868 KB Output is correct
30 Correct 217 ms 48768 KB Output is correct
31 Correct 287 ms 50756 KB Output is correct
32 Correct 165 ms 41380 KB Output is correct
33 Correct 183 ms 37628 KB Output is correct
34 Correct 218 ms 40964 KB Output is correct
35 Correct 252 ms 46692 KB Output is correct
36 Correct 224 ms 44724 KB Output is correct
37 Correct 251 ms 48296 KB Output is correct
38 Correct 211 ms 39736 KB Output is correct