Submission #381353

# Submission time Handle Problem Language Result Execution time Memory
381353 2021-03-25T06:50:13 Z asqar San (COCI17_san) C++14
48 / 120
1000 ms 372 KB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
using namespace std;
const ll maxn = 1e5 + 1;
ll n, k, H[41], G[41], a, cur, ans;
main ()
{
	cin >> n >> k;
	for (ll i = 1; i <= n; i ++)
	{
		cin >> H[i] >> G[i];
	}
	for (ll mask = 0; mask < pow (2, n); mask ++)
	{
		cur = 0, a = 0;
		for (ll i = 1; i <= n; i ++)
		{
			if ((mask >> (i - 1)) % 2 == 1)
			{
				if (cur <= H[i])
				{
					a += G[i];
					cur = H[i];
				}
				else
				{
					a = 0, cur = 0;
					break;
				}
			}
		}
		if (a >= k)
			ans ++;
	}
	cout << ans;
}

Compilation message

san.cpp:8:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main ()
      |       ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 3 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 135 ms 364 KB Output is correct
2 Correct 113 ms 372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1094 ms 364 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1090 ms 364 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1087 ms 364 KB Time limit exceeded
2 Halted 0 ms 0 KB -