답안 #1075599

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1075599 2024-08-26T07:56:40 Z Whisper Topical (NOI23_topical) C++17
21 / 100
510 ms 174824 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define int long long
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (b); i >= (a); i --)
#define REP(i, a) for (int i = 0; i < (a); ++i)
#define REPD(i, a) for (int i = (a) - 1; i >= 0; --i)

#define MASK(i) (1LL << (i))
#define BIT(x, i) (((x) >> (i)) & 1)


constexpr ll LINF = (1ll << 60);
constexpr int INF = (1ll << 30);
constexpr int Mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

/*
    Phu Trong from Nguyen Tat Thanh High School for gifted student
*/

template <class X, class Y>
    bool minimize(X &x, const Y &y){
        X eps = 1e-9;
        if (x > y + eps) {x = y; return 1;}
        return 0;
    }

template <class X, class Y>
    bool maximize(X &x, const Y &y){
        X eps = 1e-9;
        if (x + eps < y) {x = y; return 1;}
        return 0;
    }
int N, K;
#define Vec(int)            vector<vector<int>>
#define MAX                 1000005
queue<int> q;
int done[MAX];

int value[MAX], order[MAX];
void process(void){
    cin >> N >> K;
    Vec(int) U(N + 1, vector<int>(K + 1));
    Vec(int) R(N + 1, vector<int>(K + 1));

    vector<vector<pair<int, int>>> P(N + 1);
    FOR(i, 1, N) FOR(j, 1, K) cin >> R[i][j];
    FOR(i, 1, N) FOR(j, 1, K) cin >> U[i][j];

    FOR(i, 1, N) FOR(j, 1, K){
        P[j].emplace_back(make_pair(R[i][j], i));
    }

    for (int i = 1; i <= K; ++i) sort(P[i].begin(), P[i].end());

    FOR(i, 1, N){
        int ok = 1;
        FOR(j, 1, K) if(R[i][j] == 0) ++done[i];
    }
    for (int i = 1; i <= N; ++i){
        if(done[i] == K) q.emplace(i);
    }
    int ans = 0;
    while(q.size()){
        int u = q.front(); q.pop(); ++ans;
        for (int i = 1; i <= K; ++i){
            value[i] += U[u][i];
        }

        for (int i = 1; i <= K; ++i){
            for (int &j = order[i]; j < N;){
                while(j < N && value[i] >= P[i][j].first){
                    done[P[i][j].second]++;
                    if(done[P[i][j].second] == K){
                        q.emplace(P[i][j].second);
                    }
                    ++order[i];
                }
                break;
            }
        }
    }
    cout << ans;
}
signed main(){
    #define name "Whisper"
    cin.tie(nullptr) -> sync_with_stdio(false);
    //freopen(name".inp", "r", stdin);
    //freopen(name".out", "w", stdout);
    process();
    return (0 ^ 0);
}

Compilation message

Main.cpp: In function 'void process()':
Main.cpp:61:13: warning: unused variable 'ok' [-Wunused-variable]
   61 |         int ok = 1;
      |             ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 472 KB Output is correct
2 Runtime error 1 ms 604 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 436 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Runtime error 2 ms 604 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 6 ms 2516 KB Output is correct
4 Correct 38 ms 17736 KB Output is correct
5 Correct 34 ms 17356 KB Output is correct
6 Correct 486 ms 174824 KB Output is correct
7 Correct 459 ms 170384 KB Output is correct
8 Correct 510 ms 174816 KB Output is correct
9 Correct 436 ms 170332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 472 KB Output is correct
2 Runtime error 1 ms 604 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -