Submission #275309

# Submission time Handle Problem Language Result Execution time Memory
275309 2020-08-20T05:21:10 Z 최은수(#5098) Happiness (Balkan15_HAPPINESS) C++17
30 / 100
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

grader.cpp: In function 'int main()':
grader.cpp:14:9: warning: unused variable 'd' [-Wunused-variable]
   14 |  int i, d;
      |         ^
grader.cpp:15:12: warning: unused variable 'max_code' [-Wunused-variable]
   15 |  long long max_code;
      |            ^~~~~~~~
grader.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   17 |  scanf("%d%lld", &N, &M);
      |  ~~~~~^~~~~~~~~~~~~~~~~~
grader.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   19 |   scanf("%lld", &coins[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~
grader.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   23 |  scanf("%d", &Q);
      |  ~~~~~^~~~~~~~~~
grader.cpp:26:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   26 |   scanf("%d%d", &ck, &c);
      |   ~~~~~^~~~~~~~~~~~~~~~~
grader.cpp:28:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   28 |    scanf("%lld", &A[j]);
      |    ~~~~~^~~~~~~~~~~~~~~
# 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 -