답안 #1102331

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1102331 2024-10-18T02:35:26 Z ioane 나일강 (IOI24_nile) C++17
67 / 100
2000 ms 9044 KB
#include <bits/stdc++.h>
 
#define LL long long
#define PB push_back
#define MP make_pair
#define F first
#define S second

#define FF fflush(stdout)
#define d(C) C-'a'
 
const LL N = 250005;
const LL mod = 1000000007;
 
using namespace std;

std::vector<long long> calculate_costs(
    std::vector<int> W, std::vector<int> A, 
    std::vector<int> B, std::vector<int> E) {
    
    int n = W.size();
    int q = E.size();
    long long total_a = 0;
    
    // vector<pair<int, pair<int, int> > > v;
    vector<pair<int, int> > v;
    for (int i = 0; i < n; ++i){
        // v.PB(MP(W[i], MP(A[i], B[i])));
        v.PB(MP(W[i], A[i] - B[i]));
        total_a += A[i];
    }
    sort(v.begin(), v.end());
    
    std::vector<long long> result;
    
    
    for (int i_E = 0; i_E < q; ++i_E){
        int d = E[i_E];
        LL dp[n+1];
        memset(dp, 0, (n+1) * sizeof(LL));
        priority_queue<pair<LL, int> > pq;
        pq.push(MP((LL)v[0].S, v[0].F));
        for (int i = 1; i < n; ++i){
            LL ndp = dp[i-1];
            int j = i - 1;
            while (pq.size() > 0){
                pair<LL, int> sm = pq.top();
                if (sm.S + d >= v[i].F){
                    ndp = max(ndp, sm.F + v[i].S);
                    break;
                }
                pq.pop();
            }
            dp[i] = ndp;
            pq.push(MP(dp[i-1] + v[i].S, v[i].F));
        }
        LL ans = total_a - dp[n-1];
        result.PB(ans);
    }
    
    return result;
}

//      IIIIIIIII      OOOOO             A          NN        N    EEEEEEEEEE
//          I         O     O           A A         N N       N    E
//          I        O       O         A   A        N  N      N    E
//          I        O       O        A     A       N   N     N    E
//          I        O       O       AAAAAAAAA      N    N    N    EEEEEEEE
//          I        O       O      A         A     N     N   N    E
//          I        O       O     A           A    N      N  N    E
//          I         O     O     A             A   N       N N    E
//      IIIIIIIII      OOOOO     A               A  N        NN    EEEEEEEEEE ___ KAPANADZE

Compilation message

nile.cpp: In function 'std::vector<long long int> calculate_costs(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
nile.cpp:45:17: warning: unused variable 'j' [-Wunused-variable]
   45 |             int j = i - 1;
      |                 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 2 ms 508 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 8236 KB Output is correct
2 Correct 46 ms 7936 KB Output is correct
3 Correct 43 ms 8468 KB Output is correct
4 Correct 57 ms 8244 KB Output is correct
5 Correct 47 ms 7936 KB Output is correct
6 Correct 43 ms 7956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 8508 KB Output is correct
2 Correct 44 ms 8416 KB Output is correct
3 Correct 42 ms 7468 KB Output is correct
4 Correct 41 ms 7424 KB Output is correct
5 Correct 51 ms 7920 KB Output is correct
6 Correct 37 ms 7420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 2 ms 508 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 2 ms 504 KB Output is correct
8 Correct 2 ms 336 KB Output is correct
9 Correct 2 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 2 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 2 ms 508 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 46 ms 8236 KB Output is correct
8 Correct 46 ms 7936 KB Output is correct
9 Correct 43 ms 8468 KB Output is correct
10 Correct 57 ms 8244 KB Output is correct
11 Correct 47 ms 7936 KB Output is correct
12 Correct 43 ms 7956 KB Output is correct
13 Correct 53 ms 8508 KB Output is correct
14 Correct 44 ms 8416 KB Output is correct
15 Correct 42 ms 7468 KB Output is correct
16 Correct 41 ms 7424 KB Output is correct
17 Correct 51 ms 7920 KB Output is correct
18 Correct 37 ms 7420 KB Output is correct
19 Correct 2 ms 504 KB Output is correct
20 Correct 2 ms 336 KB Output is correct
21 Correct 2 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 2 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 62 ms 8420 KB Output is correct
26 Correct 53 ms 7944 KB Output is correct
27 Correct 43 ms 7480 KB Output is correct
28 Correct 48 ms 7484 KB Output is correct
29 Correct 51 ms 7496 KB Output is correct
30 Correct 45 ms 7492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 8508 KB Output is correct
2 Correct 44 ms 8416 KB Output is correct
3 Correct 42 ms 7468 KB Output is correct
4 Correct 41 ms 7424 KB Output is correct
5 Correct 51 ms 7920 KB Output is correct
6 Correct 37 ms 7420 KB Output is correct
7 Execution timed out 2062 ms 9044 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 2 ms 508 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 46 ms 8236 KB Output is correct
9 Correct 46 ms 7936 KB Output is correct
10 Correct 43 ms 8468 KB Output is correct
11 Correct 57 ms 8244 KB Output is correct
12 Correct 47 ms 7936 KB Output is correct
13 Correct 43 ms 7956 KB Output is correct
14 Correct 53 ms 8508 KB Output is correct
15 Correct 44 ms 8416 KB Output is correct
16 Correct 42 ms 7468 KB Output is correct
17 Correct 41 ms 7424 KB Output is correct
18 Correct 51 ms 7920 KB Output is correct
19 Correct 37 ms 7420 KB Output is correct
20 Correct 2 ms 504 KB Output is correct
21 Correct 2 ms 336 KB Output is correct
22 Correct 2 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 2 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 62 ms 8420 KB Output is correct
27 Correct 53 ms 7944 KB Output is correct
28 Correct 43 ms 7480 KB Output is correct
29 Correct 48 ms 7484 KB Output is correct
30 Correct 51 ms 7496 KB Output is correct
31 Correct 45 ms 7492 KB Output is correct
32 Execution timed out 2062 ms 9044 KB Time limit exceeded
33 Halted 0 ms 0 KB -