Submission #1102403

# Submission time Handle Problem Language Result Execution time Memory
1102403 2024-10-18T04:10:23 Z LTTrungCHL Topical (NOI23_topical) C++17
12 / 100
186 ms 86396 KB
///***LTT***///
/// ->NHAT QUOC GIA<- ///
#include<bits/stdc++.h>
//#pragma GCC optimize ("O3")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("popcnt")
//#define int long long
#define endl "\n"
#define F first
#define S second
#define pb push_back
using namespace std;
vector <int> lg2;
//void MAKE_LOG_ARR(int n){
//    lg2.resize(n + 3);
//    for (int i = 1;i <= n;++i){
//        lg2[i] = __lg(i);
//    }
//}
const long long oo = 1e9+7;
const int N = 2 * 1e5 + 10;
int n, k;
vector <pair <int ,int>> in[1000004];
vector <vector <int>> a;
vector <int> ok;
vector <long long> cur, cnt;
void solve(){
    cin >> n >> k;
    for (int i = 1;i <= n;++i){
        for (int j = 1;j <= k;++j){
            int v;
            cin >> v;
            in[j].pb({v, i});
        }
    }
    cur.resize(k + 2,0);
    cnt.resize(k + 2,0);
    a.resize(n + 2, vector <int> (k + 2,0));
    for (int i = 1;i <= n;++i){
        for (int j = 1;j <= k;++j){
            cin >> a[i][j];
        }
    }
    for (int i = 1;i <= k;++i){
        sort(in[i].begin(), in[i].end());
        reverse(in[i].begin(), in[i].end());
    }
    int gain = 0;
    while (1){
            ok.clear();
        for (int i = 1;i <= k;++i){
            while (!in[i].empty() and in[i].back().F <= cur[i]){
                ++cnt[in[i].back().S];

                if (cnt[in[i].back().S] == k)
                    ok.pb(in[i].back().S);
                in[i].pop_back();
            }
        }
        int sz = ok.size();
        gain += sz;
        if (!sz) break;
        for (int i : ok){
            for (int j = 1;j <= k;++j){
                cur[j] += a[i][j];
            }
        }
    }
    cout << gain;
    return;
}
int main(){
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    if (fopen("ltt.inp", "r")){
        freopen("ltt.inp", "r", stdin);
        freopen("ltt.out", "w", stdout);
    }
//    int t;
//    cin >> t;
//    while(t--){
    solve();
//    }
    return 0;
}






Compilation message

Main.cpp: In function 'int main()':
Main.cpp:77:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   77 |         freopen("ltt.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:78:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   78 |         freopen("ltt.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 23888 KB Output is correct
2 Correct 5 ms 23888 KB Output is correct
3 Correct 6 ms 24400 KB Output is correct
4 Correct 186 ms 86356 KB Output is correct
5 Correct 168 ms 86396 KB Output is correct
6 Correct 168 ms 86344 KB Output is correct
7 Correct 138 ms 86344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 23888 KB Output is correct
2 Correct 5 ms 23888 KB Output is correct
3 Correct 5 ms 23888 KB Output is correct
4 Correct 5 ms 23940 KB Output is correct
5 Correct 5 ms 23888 KB Output is correct
6 Incorrect 5 ms 23888 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 23888 KB Output is correct
2 Incorrect 6 ms 23888 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 23888 KB Output is correct
2 Correct 5 ms 23888 KB Output is correct
3 Correct 6 ms 24400 KB Output is correct
4 Correct 186 ms 86356 KB Output is correct
5 Correct 168 ms 86396 KB Output is correct
6 Correct 168 ms 86344 KB Output is correct
7 Correct 138 ms 86344 KB Output is correct
8 Correct 7 ms 23888 KB Output is correct
9 Correct 5 ms 23888 KB Output is correct
10 Correct 5 ms 23888 KB Output is correct
11 Correct 5 ms 23940 KB Output is correct
12 Correct 5 ms 23888 KB Output is correct
13 Incorrect 5 ms 23888 KB Output isn't correct
14 Halted 0 ms 0 KB -