Submission #1102337

# Submission time Handle Problem Language Result Execution time Memory
1102337 2024-10-18T02:46:07 Z TVSown Topical (NOI23_topical) C++17
100 / 100
412 ms 148648 KB
///*** Sown_Vipro ***///
/// ->GIAI BA QUOC GIA<- ///

#include<bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("popcnt")
#define F first
#define S second
#define pb push_back
#define pi pair<int, int>
#define pii pair<int, pair<int, int> >
#define FOR(i, a, b) for(int i = a; i <= b; ++i)
#define REP(i, a, b) for(int i = a; i >= b; --i)
#define inp(name) if(fopen(name, "r")) freopen(name, "r", stdin);
#define out(name) if(fopen(name, "w")) freopen(name, "w", stdout);
#define szz(s) int(s.size())
const int N = 1e6 + 5, MAX = 1e6, oo = 1e9 + 5, MOD = 1e9 + 7;
int n, k, res;
int skill[N], d[N];
vector<pi> e[N];
vector<vector<int> > r, u;
queue<int> q;
void solve(){
    cin >> n >> k;
    r = vector<vector<int> > (n + 1, vector<int> (k + 1, 0));
    u = r;

    FOR(i, 1, n){
        FOR(j, 1, k){
            cin >> r[i][j];
            e[j].pb({r[i][j], i});
        }
        d[i] = k;
    }
    FOR(j, 1, k) sort(e[j].begin(), e[j].end(), greater<pi>());

    FOR(i, 1, n){
        FOR(j, 1, k) cin >> u[i][j];
    }

    FOR(j, 1, k){
        while(szz(e[j]) && e[j].back().F <= skill[j]){
            --d[e[j].back().S];
            if(!d[e[j].back().S]) q.push(e[j].back().S);
            e[j].pop_back();
        }
    }

    while(q.size()){
        int i = q.front(); q.pop();
        ++res;
        FOR(j, 1, k){
            skill[j] += u[i][j];
            while(szz(e[j]) && e[j].back().F <= skill[j]){
                --d[e[j].back().S];
//                cout << e[j].back().S << " " << d[e[j].back().S] <<  "\n";
                if(!d[e[j].back().S]) q.push(e[j].back().S);
                e[j].pop_back();
            }
        }
    }
    cout << res;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    inp("in.txt");
    int t = 1;
//    cin >> t;
    while(t--){
        solve();
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:16:47: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 | #define inp(name) if(fopen(name, "r")) freopen(name, "r", stdin);
      |                                        ~~~~~~~^~~~~~~~~~~~~~~~~~
Main.cpp:70:5: note: in expansion of macro 'inp'
   70 |     inp("in.txt");
      |     ^~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 25168 KB Output is correct
2 Correct 5 ms 25168 KB Output is correct
3 Correct 6 ms 25680 KB Output is correct
4 Correct 182 ms 75960 KB Output is correct
5 Correct 177 ms 76032 KB Output is correct
6 Correct 180 ms 75916 KB Output is correct
7 Correct 181 ms 72192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 25168 KB Output is correct
2 Correct 5 ms 25268 KB Output is correct
3 Correct 6 ms 25168 KB Output is correct
4 Correct 5 ms 25168 KB Output is correct
5 Correct 5 ms 25212 KB Output is correct
6 Correct 5 ms 25168 KB Output is correct
7 Correct 7 ms 25592 KB Output is correct
8 Correct 6 ms 25424 KB Output is correct
9 Correct 6 ms 25424 KB Output is correct
10 Correct 8 ms 25424 KB Output is correct
11 Correct 8 ms 25424 KB Output is correct
12 Correct 7 ms 25468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 25336 KB Output is correct
2 Correct 7 ms 25168 KB Output is correct
3 Correct 11 ms 26460 KB Output is correct
4 Correct 45 ms 37392 KB Output is correct
5 Correct 37 ms 37348 KB Output is correct
6 Correct 412 ms 148604 KB Output is correct
7 Correct 385 ms 147124 KB Output is correct
8 Correct 393 ms 148648 KB Output is correct
9 Correct 400 ms 147124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 25168 KB Output is correct
2 Correct 5 ms 25168 KB Output is correct
3 Correct 6 ms 25680 KB Output is correct
4 Correct 182 ms 75960 KB Output is correct
5 Correct 177 ms 76032 KB Output is correct
6 Correct 180 ms 75916 KB Output is correct
7 Correct 181 ms 72192 KB Output is correct
8 Correct 5 ms 25168 KB Output is correct
9 Correct 5 ms 25268 KB Output is correct
10 Correct 6 ms 25168 KB Output is correct
11 Correct 5 ms 25168 KB Output is correct
12 Correct 5 ms 25212 KB Output is correct
13 Correct 5 ms 25168 KB Output is correct
14 Correct 7 ms 25592 KB Output is correct
15 Correct 6 ms 25424 KB Output is correct
16 Correct 6 ms 25424 KB Output is correct
17 Correct 8 ms 25424 KB Output is correct
18 Correct 8 ms 25424 KB Output is correct
19 Correct 7 ms 25468 KB Output is correct
20 Correct 5 ms 25336 KB Output is correct
21 Correct 7 ms 25168 KB Output is correct
22 Correct 11 ms 26460 KB Output is correct
23 Correct 45 ms 37392 KB Output is correct
24 Correct 37 ms 37348 KB Output is correct
25 Correct 412 ms 148604 KB Output is correct
26 Correct 385 ms 147124 KB Output is correct
27 Correct 393 ms 148648 KB Output is correct
28 Correct 400 ms 147124 KB Output is correct
29 Correct 191 ms 43596 KB Output is correct
30 Correct 191 ms 41288 KB Output is correct
31 Correct 229 ms 50664 KB Output is correct
32 Correct 147 ms 43252 KB Output is correct
33 Correct 160 ms 41288 KB Output is correct
34 Correct 190 ms 44616 KB Output is correct
35 Correct 237 ms 50660 KB Output is correct
36 Correct 181 ms 44700 KB Output is correct
37 Correct 208 ms 44620 KB Output is correct
38 Correct 153 ms 50660 KB Output is correct