Submission #485687

# Submission time Handle Problem Language Result Execution time Memory
485687 2021-11-09T02:12:15 Z Cross_Ratio None (JOI14_ho_t2) C++14
100 / 100
28 ms 668 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> P;
const int INF = 1e18;
signed main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int N, M;
    cin >> N >> M;
    vector<int> A;
    int i, j, a, b;
    for(i=0;i<N;i++) {
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(),A.end(),[](int x, int y) {return x > y;});
    vector<P> B;
    for(i=0;i<M;i++) {
        cin >> a >> b;
        B.push_back(P(a,b));
    }
    vector<int> sA;
    sA.resize(N+1);
    for(i=1;i<=N;i++) {
        sA[i] = sA[i-1] + A[i-1];
    }
    vector<int> C;
    C.resize(N+1);
    fill(C.begin(),C.end(),INF);
    //cout << "C\n";
    C[0] = 0;
    for(j=0;j<M;j++) {
        for(i=N;i>=0;i--) {
            int k = min(N,i+B[j].first);
            C[k] = min(C[k], C[i] + B[j].second);
        }
    }
    int ans = 0;
    for(i=0;i<=N;i++) {
        ans = max(ans, sA[i] - C[i]);
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 3 ms 580 KB Output is correct
4 Correct 3 ms 620 KB Output is correct
5 Correct 3 ms 588 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 3 ms 588 KB Output is correct
10 Correct 3 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 580 KB Output is correct
2 Correct 26 ms 580 KB Output is correct
3 Correct 27 ms 576 KB Output is correct
4 Correct 24 ms 640 KB Output is correct
5 Correct 23 ms 588 KB Output is correct
6 Correct 3 ms 332 KB Output is correct
7 Correct 18 ms 636 KB Output is correct
8 Correct 25 ms 632 KB Output is correct
9 Correct 3 ms 332 KB Output is correct
10 Correct 23 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 3 ms 580 KB Output is correct
4 Correct 3 ms 620 KB Output is correct
5 Correct 3 ms 588 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 3 ms 588 KB Output is correct
10 Correct 3 ms 588 KB Output is correct
11 Correct 28 ms 580 KB Output is correct
12 Correct 26 ms 580 KB Output is correct
13 Correct 27 ms 576 KB Output is correct
14 Correct 24 ms 640 KB Output is correct
15 Correct 23 ms 588 KB Output is correct
16 Correct 3 ms 332 KB Output is correct
17 Correct 18 ms 636 KB Output is correct
18 Correct 25 ms 632 KB Output is correct
19 Correct 3 ms 332 KB Output is correct
20 Correct 23 ms 588 KB Output is correct
21 Correct 24 ms 668 KB Output is correct
22 Correct 25 ms 628 KB Output is correct
23 Correct 25 ms 588 KB Output is correct
24 Correct 24 ms 664 KB Output is correct
25 Correct 25 ms 588 KB Output is correct
26 Correct 25 ms 632 KB Output is correct
27 Correct 5 ms 332 KB Output is correct
28 Correct 24 ms 588 KB Output is correct
29 Correct 25 ms 588 KB Output is correct
30 Correct 23 ms 640 KB Output is correct