Submission #861829

# Submission time Handle Problem Language Result Execution time Memory
861829 2023-10-17T03:46:45 Z keaucucal Self Study (JOI22_ho_t2) C++14
0 / 100
106 ms 2652 KB
// oj.uz SELF STUDY (JOI22_HO_T2)
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

using ll = long long;
const ll MAX_NUM = 1e9 * 1e9; // Ai or Bi * M

int N, M;
vector<pair<int, int>> vec;

bool ifFail(const ll passline, ll t) {
    ll comprehension = 0;
    int cnt_course = 0;
    int cnt = M;

    while(t--) {
        if(cnt_course >= passline) break;

        if(comprehension < passline) {
            if(vec[cnt_course].first > vec[cnt_course].second && cnt > 0) {
                comprehension += vec[cnt_course].first;
                cnt--;
            } else comprehension += vec[cnt_course].second;

            if(comprehension >= passline) {
                // cout << comprehension << '\n';
                cnt_course++;
                comprehension = 0;
                cnt = M;
            }
        }
    }
    // cout << passline << ' ' << cnt_course << '\n';
    return cnt_course < N;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin >> N >> M;
    int t = N * M;
    vec.resize(N);
    for(auto &i : vec) cin >> i.first;
    for(auto &i : vec) cin >> i.second;

    ll l = 1, r = MAX_NUM;
    while(l < r) {
        ll mid = (l + r) / 2 + 1;

        if(ifFail(mid, t)) {
            r = mid - 1;
        }
        else {
            l = mid;
        }
    }

    cout << l << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 106 ms 2652 KB Output is correct
12 Correct 102 ms 2648 KB Output is correct
13 Correct 57 ms 2648 KB Output is correct
14 Correct 58 ms 2648 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 43 ms 2652 KB Output is correct
17 Correct 75 ms 2652 KB Output is correct
18 Incorrect 62 ms 2652 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 43 ms 2652 KB Output is correct
3 Correct 75 ms 2652 KB Output is correct
4 Incorrect 62 ms 2652 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 106 ms 2652 KB Output is correct
12 Correct 102 ms 2648 KB Output is correct
13 Correct 57 ms 2648 KB Output is correct
14 Correct 58 ms 2648 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 43 ms 2652 KB Output is correct
17 Correct 75 ms 2652 KB Output is correct
18 Incorrect 62 ms 2652 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 43 ms 2652 KB Output is correct
3 Correct 75 ms 2652 KB Output is correct
4 Incorrect 62 ms 2652 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 106 ms 2652 KB Output is correct
12 Correct 102 ms 2648 KB Output is correct
13 Correct 57 ms 2648 KB Output is correct
14 Correct 58 ms 2648 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 43 ms 2652 KB Output is correct
17 Correct 75 ms 2652 KB Output is correct
18 Incorrect 62 ms 2652 KB Output isn't correct
19 Halted 0 ms 0 KB -