답안 #965015

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
965015 2024-04-18T03:09:54 Z vjudge1 Gym Badges (NOI22_gymbadges) C++17
100 / 100
143 ms 21932 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define int long long
#define FOR(i, a, b) for (int i = a; i <= b; i++)
#define FORD(i, a, b) for (int i = b; i >= a; i --)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPD(i, n) for (int i = n - 1; i >= 0; --i)

#define MASK(i) (1LL << (i))
#define BIT(x, i) (((x) >> (i)) & 1)

constexpr ll LINF = (1ll << 60);
constexpr int INF = (1ll << 30);
constexpr int Mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void setupIO(){
    #define name "Whisper"
    //Phu Trong from Nguyen Tat Thanh High School for gifted student
    srand(time(NULL));
    cin.tie(nullptr)->sync_with_stdio(false); cout.tie(nullptr);
    //freopen(name".inp", "r", stdin);
    //freopen(name".out", "w", stdout);
    cout << fixed << setprecision(10);
}

template <class X, class Y>
    bool minimize(X &x, const Y &y){
        X eps = 1e-9;
        if (x > y + eps) {x = y; return 1;}
        return 0;
    }

template <class X, class Y>
    bool maximize(X &x, const Y &y){
        X eps = 1e-9;
        if (x + eps < y) {x = y; return 1;}
        return 0;
    }
const int MAX = 5e5 + 5;
struct Data{
    int x, l;

    bool operator < (const Data& oth) const{
        return x + l < oth.x + oth.l;
    }
} a[MAX];

int nArr;
void Whisper(){
    cin >> nArr;
    FOR(i, 1, nArr) cin >> a[i].x;
    FOR(i, 1, nArr) cin >> a[i].l;

    sort(a + 1, a + nArr + 1);
    priority_queue<int> q;
    int sum = 0, ans = 0;
    for (int i = 1; i <= nArr; ++i){
        if (sum > a[i].l){
            if(q.top() > a[i].x){
                sum -= q.top(); q.pop();
                sum += a[i].x; q.push(a[i].x);
            }
        }
        else{
            sum += a[i].x;
            q.push(a[i].x);
        }
        maximize(ans, (int)q.size());
    }
    cout << ans;
}


signed main(){
    setupIO();
    int Test = 1;
//    cin >> Test;
    for ( int i = 1 ; i <= Test ; i++ ){
        Whisper();
        if (i < Test) cout << '\n';
    }
}


# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 472 KB Output is correct
10 Correct 0 ms 468 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 468 KB Output is correct
20 Correct 0 ms 356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 115 ms 17244 KB Output is correct
2 Correct 116 ms 17256 KB Output is correct
3 Correct 112 ms 17524 KB Output is correct
4 Correct 112 ms 17328 KB Output is correct
5 Correct 115 ms 17480 KB Output is correct
6 Correct 113 ms 16720 KB Output is correct
7 Correct 122 ms 15960 KB Output is correct
8 Correct 111 ms 16724 KB Output is correct
9 Correct 107 ms 16712 KB Output is correct
10 Correct 106 ms 16832 KB Output is correct
11 Correct 106 ms 17700 KB Output is correct
12 Correct 110 ms 21212 KB Output is correct
13 Correct 103 ms 17584 KB Output is correct
14 Correct 109 ms 20148 KB Output is correct
15 Correct 99 ms 19768 KB Output is correct
16 Correct 108 ms 17064 KB Output is correct
17 Correct 106 ms 17088 KB Output is correct
18 Correct 108 ms 16880 KB Output is correct
19 Correct 106 ms 16372 KB Output is correct
20 Correct 113 ms 16488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 472 KB Output is correct
10 Correct 0 ms 468 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 468 KB Output is correct
20 Correct 0 ms 356 KB Output is correct
21 Correct 1 ms 604 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 2 ms 604 KB Output is correct
24 Correct 2 ms 604 KB Output is correct
25 Correct 2 ms 636 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 2 ms 600 KB Output is correct
29 Correct 1 ms 604 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 1 ms 488 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 2 ms 600 KB Output is correct
35 Correct 2 ms 604 KB Output is correct
36 Correct 2 ms 604 KB Output is correct
37 Correct 2 ms 604 KB Output is correct
38 Correct 2 ms 604 KB Output is correct
39 Correct 2 ms 604 KB Output is correct
40 Correct 2 ms 604 KB Output is correct
41 Correct 2 ms 600 KB Output is correct
42 Correct 2 ms 604 KB Output is correct
43 Correct 2 ms 604 KB Output is correct
44 Correct 2 ms 600 KB Output is correct
45 Correct 2 ms 604 KB Output is correct
46 Correct 2 ms 480 KB Output is correct
47 Correct 2 ms 856 KB Output is correct
48 Correct 2 ms 604 KB Output is correct
49 Correct 1 ms 604 KB Output is correct
50 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 472 KB Output is correct
10 Correct 0 ms 468 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 468 KB Output is correct
20 Correct 0 ms 356 KB Output is correct
21 Correct 115 ms 17244 KB Output is correct
22 Correct 116 ms 17256 KB Output is correct
23 Correct 112 ms 17524 KB Output is correct
24 Correct 112 ms 17328 KB Output is correct
25 Correct 115 ms 17480 KB Output is correct
26 Correct 113 ms 16720 KB Output is correct
27 Correct 122 ms 15960 KB Output is correct
28 Correct 111 ms 16724 KB Output is correct
29 Correct 107 ms 16712 KB Output is correct
30 Correct 106 ms 16832 KB Output is correct
31 Correct 106 ms 17700 KB Output is correct
32 Correct 110 ms 21212 KB Output is correct
33 Correct 103 ms 17584 KB Output is correct
34 Correct 109 ms 20148 KB Output is correct
35 Correct 99 ms 19768 KB Output is correct
36 Correct 108 ms 17064 KB Output is correct
37 Correct 106 ms 17088 KB Output is correct
38 Correct 108 ms 16880 KB Output is correct
39 Correct 106 ms 16372 KB Output is correct
40 Correct 113 ms 16488 KB Output is correct
41 Correct 1 ms 604 KB Output is correct
42 Correct 1 ms 604 KB Output is correct
43 Correct 2 ms 604 KB Output is correct
44 Correct 2 ms 604 KB Output is correct
45 Correct 2 ms 636 KB Output is correct
46 Correct 1 ms 604 KB Output is correct
47 Correct 1 ms 604 KB Output is correct
48 Correct 2 ms 600 KB Output is correct
49 Correct 1 ms 604 KB Output is correct
50 Correct 1 ms 604 KB Output is correct
51 Correct 2 ms 604 KB Output is correct
52 Correct 1 ms 488 KB Output is correct
53 Correct 2 ms 604 KB Output is correct
54 Correct 2 ms 600 KB Output is correct
55 Correct 2 ms 604 KB Output is correct
56 Correct 2 ms 604 KB Output is correct
57 Correct 2 ms 604 KB Output is correct
58 Correct 2 ms 604 KB Output is correct
59 Correct 2 ms 604 KB Output is correct
60 Correct 2 ms 604 KB Output is correct
61 Correct 2 ms 600 KB Output is correct
62 Correct 2 ms 604 KB Output is correct
63 Correct 2 ms 604 KB Output is correct
64 Correct 2 ms 600 KB Output is correct
65 Correct 2 ms 604 KB Output is correct
66 Correct 2 ms 480 KB Output is correct
67 Correct 2 ms 856 KB Output is correct
68 Correct 2 ms 604 KB Output is correct
69 Correct 1 ms 604 KB Output is correct
70 Correct 1 ms 604 KB Output is correct
71 Correct 1 ms 348 KB Output is correct
72 Correct 0 ms 348 KB Output is correct
73 Correct 113 ms 17480 KB Output is correct
74 Correct 128 ms 17548 KB Output is correct
75 Correct 119 ms 17468 KB Output is correct
76 Correct 125 ms 16968 KB Output is correct
77 Correct 121 ms 16836 KB Output is correct
78 Correct 124 ms 18224 KB Output is correct
79 Correct 121 ms 18288 KB Output is correct
80 Correct 117 ms 18168 KB Output is correct
81 Correct 115 ms 18240 KB Output is correct
82 Correct 112 ms 18380 KB Output is correct
83 Correct 117 ms 18856 KB Output is correct
84 Correct 115 ms 18668 KB Output is correct
85 Correct 136 ms 18780 KB Output is correct
86 Correct 118 ms 18728 KB Output is correct
87 Correct 123 ms 18888 KB Output is correct
88 Correct 143 ms 20492 KB Output is correct
89 Correct 121 ms 20168 KB Output is correct
90 Correct 112 ms 20156 KB Output is correct
91 Correct 119 ms 21216 KB Output is correct
92 Correct 123 ms 20240 KB Output is correct
93 Correct 121 ms 21932 KB Output is correct
94 Correct 117 ms 20912 KB Output is correct
95 Correct 132 ms 20172 KB Output is correct
96 Correct 121 ms 21068 KB Output is correct
97 Correct 109 ms 20656 KB Output is correct
98 Correct 113 ms 17740 KB Output is correct
99 Correct 128 ms 17300 KB Output is correct
100 Correct 119 ms 17228 KB Output is correct
101 Correct 112 ms 19932 KB Output is correct
102 Correct 116 ms 19092 KB Output is correct