답안 #442760

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
442760 2021-07-08T22:43:15 Z SirCovidThe19th Happiness (Balkan15_HAPPINESS) C++14
100 / 100
475 ms 16068 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long

multiset<ll> group[40]; ll sum[40]; 

void upd(ll x, int op){ int g = log2(x);
    if (op == -1) group[g].erase(group[g].find(x)), sum[g] -= x;
    else group[g].insert(x), sum[g] += x;
}
bool solve(){
    ll tot = 0;
    for (int i = 0; i < 40; i++){ 
        if (group[i].size() > 0) if (tot < *group[i].begin()-1) return 0;
        if (group[i].size() > 1) if (tot+*group[i].begin() < *next(group[i].begin())-1) return 0;
        tot += sum[i];
    }return 1;
}
bool init(int n, ll mx, ll coins[]){
    for (int i = 0; i < n; i++) upd(coins[i], 1);
    return solve();
}
bool is_happy(int op, int n, ll coins[]){
    for (int i = 0; i < n; i++) upd(coins[i], op);
    return solve();
}


Compilation message

grader.cpp: In function 'int main()':
grader.cpp:16:12: warning: unused variable 'max_code' [-Wunused-variable]
   16 |  long long max_code;
      |            ^~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 7 ms 972 KB Output is correct
9 Correct 7 ms 972 KB Output is correct
10 Correct 6 ms 972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 220 ms 9028 KB Output is correct
7 Correct 206 ms 8940 KB Output is correct
8 Correct 218 ms 9000 KB Output is correct
9 Correct 325 ms 10444 KB Output is correct
10 Correct 475 ms 13164 KB Output is correct
11 Correct 214 ms 13524 KB Output is correct
12 Correct 211 ms 13632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 7 ms 972 KB Output is correct
9 Correct 7 ms 972 KB Output is correct
10 Correct 6 ms 972 KB Output is correct
11 Correct 220 ms 9028 KB Output is correct
12 Correct 206 ms 8940 KB Output is correct
13 Correct 218 ms 9000 KB Output is correct
14 Correct 325 ms 10444 KB Output is correct
15 Correct 475 ms 13164 KB Output is correct
16 Correct 214 ms 13524 KB Output is correct
17 Correct 211 ms 13632 KB Output is correct
18 Correct 305 ms 11412 KB Output is correct
19 Correct 243 ms 11332 KB Output is correct
20 Correct 397 ms 14344 KB Output is correct
21 Correct 249 ms 10780 KB Output is correct
22 Correct 223 ms 15552 KB Output is correct
23 Correct 230 ms 16068 KB Output is correct
24 Correct 244 ms 11344 KB Output is correct