Submission #862056

#TimeUsernameProblemLanguageResultExecution timeMemory
862056normankr07Olympic Bus (JOI20_ho_t4)C++17
0 / 100
193 ms262144 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...