답안 #1107428

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1107428 2024-11-01T08:25:08 Z 12345678 Topical (NOI23_topical) C++17
100 / 100
595 ms 148516 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

ll n, k, cnt;
vector<ll> cur, sm;
vector<vector<ll>> r, u;
vector<priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>> pq;
queue<ll> q;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n>>k;
    cur.resize(k);
    sm.resize(n);
    pq.resize(k);
    r.resize(n);
    u.resize(n);
    for (int i=0; i<n; i++) r[i].resize(k), u[i].resize(k);
    for (int i=0; i<n; i++) for (int j=0; j<k; j++) cin>>r[i][j], sm[i]+=r[i][j];
    for (int i=0; i<n; i++) for (int j=0; j<k; j++) cin>>u[i][j];
    for (int i=0; i<n; i++) 
    {
        if (sm[i]==0) q.push(i);
        else pq[0].push({r[i][0], i});
    }
    while (!q.empty())
    {
        while (!q.empty())
        {
            auto x=q.front();
            for (int i=0; i<k; i++) cur[i]+=u[x][i];
            q.pop();
            cnt++;
        }
        for (int i=0; i<k; i++) 
        {
            while (!pq[i].empty()&&pq[i].top().first<=cur[i])
            {
                ll tmp=pq[i].top().second;
                pq[i].pop();
                if (i==k-1) q.push(tmp);
                else pq[i+1].push({r[tmp][i+1], tmp});
            }
        }
    }
    cout<<cnt;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 508 KB Output is correct
3 Correct 2 ms 848 KB Output is correct
4 Correct 111 ms 55120 KB Output is correct
5 Correct 114 ms 55120 KB Output is correct
6 Correct 122 ms 55120 KB Output is correct
7 Correct 90 ms 55120 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 592 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 504 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 508 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 3 ms 592 KB Output is correct
8 Correct 2 ms 592 KB Output is correct
9 Correct 2 ms 592 KB Output is correct
10 Correct 2 ms 764 KB Output is correct
11 Correct 3 ms 592 KB Output is correct
12 Correct 2 ms 592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 4 ms 1872 KB Output is correct
4 Correct 35 ms 15300 KB Output is correct
5 Correct 37 ms 15404 KB Output is correct
6 Correct 519 ms 136772 KB Output is correct
7 Correct 595 ms 146956 KB Output is correct
8 Correct 485 ms 148516 KB Output is correct
9 Correct 580 ms 146976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 508 KB Output is correct
3 Correct 2 ms 848 KB Output is correct
4 Correct 111 ms 55120 KB Output is correct
5 Correct 114 ms 55120 KB Output is correct
6 Correct 122 ms 55120 KB Output is correct
7 Correct 90 ms 55120 KB Output is correct
8 Correct 1 ms 592 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 504 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 508 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 3 ms 592 KB Output is correct
15 Correct 2 ms 592 KB Output is correct
16 Correct 2 ms 592 KB Output is correct
17 Correct 2 ms 764 KB Output is correct
18 Correct 3 ms 592 KB Output is correct
19 Correct 2 ms 592 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 4 ms 1872 KB Output is correct
23 Correct 35 ms 15300 KB Output is correct
24 Correct 37 ms 15404 KB Output is correct
25 Correct 519 ms 136772 KB Output is correct
26 Correct 595 ms 146956 KB Output is correct
27 Correct 485 ms 148516 KB Output is correct
28 Correct 580 ms 146976 KB Output is correct
29 Correct 185 ms 30512 KB Output is correct
30 Correct 164 ms 29568 KB Output is correct
31 Correct 210 ms 39360 KB Output is correct
32 Correct 130 ms 25472 KB Output is correct
33 Correct 129 ms 26204 KB Output is correct
34 Correct 129 ms 27076 KB Output is correct
35 Correct 196 ms 39424 KB Output is correct
36 Correct 193 ms 31940 KB Output is correct
37 Correct 170 ms 32960 KB Output is correct
38 Correct 195 ms 36292 KB Output is correct