Submission #841675

# Submission time Handle Problem Language Result Execution time Memory
841675 2023-09-01T20:28:32 Z kwongweng Topical (NOI23_topical) C++17
12 / 100
460 ms 102072 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long double ld;
typedef pair<ll, ll> pll;
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define ROF(i, a, b) for(int i = a; i >= b; i--)
#define ms memset
#define pb push_back
#define fi first
#define se second

int main(){
    int n, k; cin>>n>>k;
    ll r[n][k], u[n][k];
    vector<pair<ll,int>> arr[k];
    FOR(i,0,n){
        FOR(j,0,k) cin>>r[i][j];
    }
    FOR(j,0,k){
        FOR(i,0,n) arr[j].pb({r[i][j], i});
        sort(arr[j].begin(), arr[j].end());
    }
    FOR(i,0,n){
        FOR(j,0,k) cin>>u[i][j];
    }
    int mat[n][k]; ms(mat,0,sizeof(mat));
    vi cnt(k);
    vi bfs;
    vector<ll> p(k); vi cur(k);
    FOR(j,0,k){
        while (cur[j] < n && p[j] >= arr[j][cur[j]].fi){
            int pos = arr[j][cur[j]].se;
            cnt[pos]++;
            if (cnt[pos]==k){
                bfs.pb(pos);
            }
            cur[j]++;
        }
    }
    FOR(i,0,bfs.size()){
        //cout<<bfs[i]<<"\n";
        int ind = bfs[i];
        FOR(j,0,k){
            p[j] += u[ind][j];
            while (cur[j] < n && p[j] >= arr[j][cur[j]].fi){
                int pos = arr[j][cur[j]].se;
                cnt[pos]++;
                if (cnt[pos]==k){
                    bfs.pb(pos);
                }
                cur[j]++;
            }
        }
        
    }
    cout<<bfs.size()<<"\n";
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:10:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 | #define FOR(i, a, b) for(int i = a; i < b; i++)
......
   45 |     FOR(i,0,bfs.size()){
      |         ~~~~~~~~~~~~~~                 
Main.cpp:45:5: note: in expansion of macro 'FOR'
   45 |     FOR(i,0,bfs.size()){
      |     ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 5 ms 1372 KB Output is correct
4 Correct 460 ms 101992 KB Output is correct
5 Correct 460 ms 102072 KB Output is correct
6 Correct 446 ms 101840 KB Output is correct
7 Correct 315 ms 96232 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 436 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 600 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 5 ms 1372 KB Output is correct
4 Correct 460 ms 101992 KB Output is correct
5 Correct 460 ms 102072 KB Output is correct
6 Correct 446 ms 101840 KB Output is correct
7 Correct 315 ms 96232 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 436 KB Output is correct
13 Incorrect 0 ms 348 KB Output isn't correct
14 Halted 0 ms 0 KB -