Submission #971627

# Submission time Handle Problem Language Result Execution time Memory
971627 2024-04-29T05:24:40 Z Arteezy Divide and conquer (IZhO14_divide) C++17
48 / 100
1000 ms 2648 KB
#include <bits/stdc++.h>

using namespace std;
#define int long long
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<vector<long long >> vll;
typedef vector<long long> vl;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//
//using namespace __gnu_pbds;

//template<class T> using ordered_set =
//        tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//template<class T> using ordered_multiset =
//        tree<T, null_type, greater_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
struct Rudnik {
    int coordinate, gold, energy;
};

signed main() {
//        cout.setf(ios::fixed);
//        cout.precision(0);
    ios_base::sync_with_stdio(false);
    cout.tie(NULL);
    cin.tie(NULL);

    int n;
    cin >> n;
    vector<Rudnik> arr(n);
    for (int i = 0; i < n; ++i) {
        cin >> arr[i].coordinate >> arr[i].gold >> arr[i].energy;
    }

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int tmp = arr[i].gold;
        int energy = arr[i].energy;
        int size = 0;
        for (int j = i+1; j < n; ++j) {
            if (size <= energy){
                ans = max(ans, tmp);
            }
            tmp += arr[j].gold;
            energy += arr[j].energy;
            size += arr[j].coordinate - arr[j-1].coordinate;
        }
        if (size <= energy){
            ans = max(ans, tmp);
        }
    }
    cout << ans;


}
# 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 344 KB Output is correct
5 Correct 0 ms 344 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 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
# 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 344 KB Output is correct
5 Correct 0 ms 344 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 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 2 ms 344 KB Output is correct
23 Correct 10 ms 604 KB Output is correct
24 Correct 10 ms 600 KB Output is correct
# 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 344 KB Output is correct
5 Correct 0 ms 344 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 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 2 ms 344 KB Output is correct
23 Correct 10 ms 604 KB Output is correct
24 Correct 10 ms 600 KB Output is correct
25 Correct 13 ms 604 KB Output is correct
26 Correct 50 ms 604 KB Output is correct
27 Correct 49 ms 860 KB Output is correct
28 Execution timed out 1022 ms 2648 KB Time limit exceeded
29 Halted 0 ms 0 KB -