Submission #862056

# Submission time Handle Problem Language Result Execution time Memory
862056 2023-10-17T13:06:40 Z normankr07 Olympic Bus (JOI20_ho_t4) C++17
0 / 100
193 ms 262144 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define fileio(name) if (fopen(name".inp", "r")) freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout)

const int maxn = 2e5+4;
int n, m, a[maxn];
vector<int> t[maxn];

bool check(int val) {
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        for (int j: t[i]) {
            cnt += (j <= val);
        }
        val += a[i];
    }
    return cnt >= m;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    fileio("");
    // freopen("debug.txt", "w", stderr);

    cin >> n >> m;
    int sum = 0, k = 0;
    for (int i = 1; i <= n; i++) {
        int b;
        cin >> a[i] >> b;
        sum += a[i]; k += b;
        while (b--) {
            int x; cin >> x;
            t[i].push_back(x);
        }
    }
    m = min(m, k);

    int l = 0, r = 1e16;
    while (l <= r) {
        int mid = (l+r)>>1;
        if (check(mid)) r = mid-1;
        else l = mid+1;
    }
    cout << l + sum;

    return 0 ^ 0;
}

Compilation message

ho_t4.cpp: In function 'int32_t main()':
ho_t4.cpp:5:57: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define fileio(name) if (fopen(name".inp", "r")) freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout)
      |                                                  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ho_t4.cpp:25:5: note: in expansion of macro 'fileio'
   25 |     fileio("");
      |     ^~~~~~
ho_t4.cpp:5:90: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define fileio(name) if (fopen(name".inp", "r")) freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout)
      |                                                                                   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
ho_t4.cpp:25:5: note: in expansion of macro 'fileio'
   25 |     fileio("");
      |     ^~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 170 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 193 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 175 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 170 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -