# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
275309 | 2020-08-20T05:21:10 Z | 최은수(#5098) | Happiness (Balkan15_HAPPINESS) | C++17 | 2000 ms | 4124 KB |
#include"happiness.h" #include<iostream> #include<vector> #include<algorithm> #define ep emplace #define eb emplace_back #define fi first #define se second #define all(x) (x).begin(),(x).end() using namespace std; typedef long long ll; typedef pair<int,int>pi; typedef pair<ll,ll>pl; const int inf=1e9+7; const ll INF=1e18; vector<ll>lst; inline bool check() { ll prf=1; for(ll&t:lst) { if(t>prf) return 0; prf+=t; } return 1; } bool init(int coinsCount,ll maxCoinSize,ll coins[]) { for(int i=0;i<coinsCount;i++) lst.eb(coins[i]); sort(all(lst)); return check(); } bool is_happy(int event,int coinsCount,ll coins[]) { vector<ll>cur; for(int i=0;i<coinsCount;i++) cur.eb(coins[i]); sort(all(cur)); if(event==1) { vector<ll>nxt; int i=0,j=0; while(i<(int)lst.size()&&j<(int)cur.size()) { if(lst[i]<cur[j]) nxt.eb(lst[i++]); else nxt.eb(cur[j++]); } while(i<(int)lst.size()||j<(int)cur.size()) { if(j==(int)cur.size()) nxt.eb(lst[i++]); else nxt.eb(cur[j++]); } lst=nxt; } else { vector<ll>nxt; int i=0; for(int j=0;j<(int)cur.size();j++) { while(lst[i]<cur[j]) nxt.eb(lst[i++]); i++; } while(i<(int)lst.size()) nxt.eb(lst[i++]); lst=nxt; } return check(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 64 ms | 948 KB | Output is correct |
9 | Correct | 75 ms | 948 KB | Output is correct |
10 | Correct | 86 ms | 1060 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Execution timed out | 2064 ms | 4124 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 64 ms | 948 KB | Output is correct |
9 | Correct | 75 ms | 948 KB | Output is correct |
10 | Correct | 86 ms | 1060 KB | Output is correct |
11 | Execution timed out | 2064 ms | 4124 KB | Time limit exceeded |
12 | Halted | 0 ms | 0 KB | - |