# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
73213 | 2018-08-28T04:52:19 Z | 윤교준(#2271) | Happiness (Balkan15_HAPPINESS) | C++11 | 720 ms | 10412 KB |
#include "happiness.h" #include <bits/stdc++.h> #define pb push_back #define eb emplace_back #define sz(V) ((int)(V).size()) #define allv(V) ((V).begin()),((V).end()) #define sorv(V) sort(allv(V)) #define revv(V) reverse(allv(V)) #define univ(V) (V).erase(unique(allv(V)),(V).end()) #define clv(V) (V).clear() #define upmin(a,b) (a)=min((a),(b)) #define upmax(a,b) (a)=max((a),(b)) #define rb(x) ((x)&(-(x))) #define INF (0x3f3f3f3f) #define INFLL (0x3f3f3f3f3f3f3f3fll) using namespace std; typedef long long ll; typedef pair<int, int> pii; multiset<ll> CH[40]; ll S[40]; int getIdx(ll n) { for(int i = 1;; i++) { if(n < (1ll<<i)) return i-1; } } bool getAns() { ll sum = 0, tot = 0; for(int i = 0; i < 40; i++) tot += S[i]; for(int i = 0; i < 40; i++) { if(CH[i].empty()) continue; if(sum+1 < *CH[i].begin()) break; sum += S[i]; } return sum == tot; } bool init(int cnt, ll mxcoin, ll A[]) { for(int i = 0, t; i < cnt; i++) { t = getIdx(A[i]); S[t] += A[i]; CH[t].insert(A[i]); } return getAns(); } bool is_happy(int evt, int cnt, ll A[]) { if(0 < evt) { for(int i = 0, t; i < cnt; i++) { t = getIdx(A[i]); S[t] += A[i]; CH[t].insert(A[i]); } } else { for(int i = 0, t; i < cnt; i++) { t = getIdx(A[i]); S[t] -= A[i]; CH[t].erase(CH[t].find(A[i])); } } return getAns(); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 488 KB | Output is correct |
3 | Correct | 3 ms | 488 KB | Output is correct |
4 | Correct | 4 ms | 488 KB | Output is correct |
5 | Correct | 3 ms | 500 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 544 KB | Output is correct |
2 | Correct | 3 ms | 572 KB | Output is correct |
3 | Correct | 11 ms | 1088 KB | Output is correct |
4 | Correct | 14 ms | 1088 KB | Output is correct |
5 | Correct | 11 ms | 1088 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 296 ms | 6332 KB | Output is correct |
2 | Correct | 268 ms | 6332 KB | Output is correct |
3 | Correct | 278 ms | 6372 KB | Output is correct |
4 | Correct | 606 ms | 6372 KB | Output is correct |
5 | Correct | 720 ms | 8960 KB | Output is correct |
6 | Correct | 220 ms | 10248 KB | Output is correct |
7 | Correct | 246 ms | 10248 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 357 ms | 10248 KB | Output is correct |
2 | Correct | 455 ms | 10248 KB | Output is correct |
3 | Correct | 618 ms | 10248 KB | Output is correct |
4 | Correct | 355 ms | 10248 KB | Output is correct |
5 | Correct | 282 ms | 10248 KB | Output is correct |
6 | Correct | 275 ms | 10412 KB | Output is correct |
7 | Correct | 335 ms | 10412 KB | Output is correct |