답안 #970711

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
970711 2024-04-27T06:50:08 Z CSQ31 Topical (NOI23_topical) C++17
100 / 100
483 ms 163460 KB
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) (int)(a.size())
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(998244353)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
const int MAXN = 1e6+1;
vector<int>r[MAXN],u[MAXN];
vector<ll>p;
vector<pii>ord[MAXN];
int cnt[MAXN],idx[MAXN];
int main()
{
    owo
    int n,k;
    cin>>n>>k;

    p.assign(k,0);

    for(int i=0;i<n;i++){
        cnt[i] = k;
        r[i].resize(k);
        for(int j=0;j<k;j++){
            cin>>r[i][j];
            ord[j].pb({r[i][j],i});
        }
    }
    for(int i=0;i<n;i++){
        u[i].resize(k);
        for(int j=0;j<k;j++)cin>>u[i][j];
    }    
    queue<int>q;
    for(int j=0;j<k;j++){
        sort(all(ord[j]));
        idx[j] = -1;
        while(idx[j]+1 < n && ord[j][idx[j]+1].fi <= p[j]){
            idx[j]++;
            int x = ord[j][idx[j]].se;
            cnt[x]--;
            if(!cnt[x])q.push(x);

        }
    }
    ll ans = 0;
    while(!q.empty())
    {
        int v = q.front();
        q.pop();
        ans++;
        for(int j=0;j<k;j++)p[j] += u[v][j];
        for(int j=0;j<k;j++){
            while(idx[j]+1 < n && ord[j][idx[j]+1].fi <= p[j]){
                idx[j]++;
                int x = ord[j][idx[j]].se;
                cnt[x]--;
                if(!cnt[x])q.push(x);
            }
        }
    }
    cout<<ans<<'\n';
}   
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 74320 KB Output is correct
2 Correct 22 ms 74332 KB Output is correct
3 Correct 18 ms 75100 KB Output is correct
4 Correct 190 ms 135092 KB Output is correct
5 Correct 183 ms 135176 KB Output is correct
6 Correct 191 ms 135256 KB Output is correct
7 Correct 148 ms 129368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 74332 KB Output is correct
2 Correct 16 ms 74328 KB Output is correct
3 Correct 17 ms 74328 KB Output is correct
4 Correct 16 ms 74332 KB Output is correct
5 Correct 17 ms 74332 KB Output is correct
6 Correct 18 ms 74464 KB Output is correct
7 Correct 18 ms 74840 KB Output is correct
8 Correct 19 ms 74588 KB Output is correct
9 Correct 19 ms 74680 KB Output is correct
10 Correct 22 ms 74844 KB Output is correct
11 Correct 19 ms 74584 KB Output is correct
12 Correct 20 ms 74588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 74332 KB Output is correct
2 Correct 16 ms 74344 KB Output is correct
3 Correct 20 ms 75100 KB Output is correct
4 Correct 51 ms 84880 KB Output is correct
5 Correct 47 ms 84676 KB Output is correct
6 Correct 434 ms 163460 KB Output is correct
7 Correct 425 ms 160104 KB Output is correct
8 Correct 483 ms 163108 KB Output is correct
9 Correct 406 ms 160172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 74320 KB Output is correct
2 Correct 22 ms 74332 KB Output is correct
3 Correct 18 ms 75100 KB Output is correct
4 Correct 190 ms 135092 KB Output is correct
5 Correct 183 ms 135176 KB Output is correct
6 Correct 191 ms 135256 KB Output is correct
7 Correct 148 ms 129368 KB Output is correct
8 Correct 17 ms 74332 KB Output is correct
9 Correct 16 ms 74328 KB Output is correct
10 Correct 17 ms 74328 KB Output is correct
11 Correct 16 ms 74332 KB Output is correct
12 Correct 17 ms 74332 KB Output is correct
13 Correct 18 ms 74464 KB Output is correct
14 Correct 18 ms 74840 KB Output is correct
15 Correct 19 ms 74588 KB Output is correct
16 Correct 19 ms 74680 KB Output is correct
17 Correct 22 ms 74844 KB Output is correct
18 Correct 19 ms 74584 KB Output is correct
19 Correct 20 ms 74588 KB Output is correct
20 Correct 17 ms 74332 KB Output is correct
21 Correct 16 ms 74344 KB Output is correct
22 Correct 20 ms 75100 KB Output is correct
23 Correct 51 ms 84880 KB Output is correct
24 Correct 47 ms 84676 KB Output is correct
25 Correct 434 ms 163460 KB Output is correct
26 Correct 425 ms 160104 KB Output is correct
27 Correct 483 ms 163108 KB Output is correct
28 Correct 406 ms 160172 KB Output is correct
29 Correct 220 ms 110640 KB Output is correct
30 Correct 223 ms 107600 KB Output is correct
31 Correct 263 ms 108860 KB Output is correct
32 Correct 172 ms 101288 KB Output is correct
33 Correct 196 ms 100440 KB Output is correct
34 Correct 218 ms 102736 KB Output is correct
35 Correct 249 ms 105316 KB Output is correct
36 Correct 221 ms 105972 KB Output is correct
37 Correct 237 ms 108608 KB Output is correct
38 Correct 168 ms 97772 KB Output is correct