Submission #381356

# Submission time Handle Problem Language Result Execution time Memory
381356 2021-03-25T06:56:59 Z asqar San (COCI17_san) C++14
48 / 120
60 ms 364 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 ()
{
	ios_base::sync_with_stdio (0);
	cin.tie (0);

	cin >> n >> k;
	for (ll i = 1; i <= n; i ++)
	{
		cin >> H[i] >> G[i];
	}
	ll po = (1 << n);
	for (ll mask = 0; mask < po; mask ++)
	{
		cur = 0, a = 0;
		for (ll i = mask, j = 1; i > 0; i = i = (i >> 1),j ++)
		{
			if (i % 2 == 1)
			{
				if (cur <= H[j])
				{
					a += G[j];
					cur = H[j];
				}
				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 ()
      |       ^
san.cpp: In function 'int main()':
san.cpp:22:37: warning: operation on 'i' may be undefined [-Wsequence-point]
   22 |   for (ll i = mask, j = 1; i > 0; i = i = (i >> 1),j ++)
      |                                   ~~^~~~~~~~~~~~~~
san.cpp:22:37: warning: operation on 'i' may be undefined [-Wsequence-point]
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 60 ms 364 KB Output is correct
2 Correct 17 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -