99242024-03-18 17:10:46CWMSzitakötő (50 pont)cpp17Wrong answer 8/5048ms7904 KiB
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <climits>

using namespace std;

#define int long long

int twopow(int exponent) {
	int cR = 1;
	for (size_t i = 0; i < exponent; i++)
	{
		cR = (2 * cR) % 1000000007;
	}
	return cR;
}

signed main()
{
    int n, k;
	cin >> n >> k;
    k--;
	vector<int> inp(n);
	vector<int> prefix(n + 1);
	for (size_t i = 0; i < n; i++)
	{
		cin >> inp[i];
		prefix[i + 1] = prefix[i] + inp[i];
	}
	int twoPower = 0;
	for (size_t i = 0; i < n; i++)
	{
		if (2 * prefix[i] > prefix[k + 1]) {
			twoPower = i - 1;
			break;
		}
	}
	int twoPower2 = 0;
	for (size_t i = k+1; i < n+1; i++)
	{
		if (2 * prefix[i] > prefix[n]) {
			twoPower2 = (n - i);
			break;
		}
	}
	if (k == n - 1) twoPower++;
	cout << twopow(twoPower + twoPower2);
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base8/50
1Accepted0/03ms1808 KiB
2Wrong answer0/048ms5048 KiB
3Wrong answer0/13ms2216 KiB
4Accepted1/13ms2456 KiB
5Wrong answer0/13ms2708 KiB
6Accepted1/13ms2920 KiB
7Wrong answer0/12ms3000 KiB
8Wrong answer0/12ms3064 KiB
9Wrong answer0/13ms3192 KiB
10Wrong answer0/23ms3404 KiB
11Wrong answer0/23ms3524 KiB
12Wrong answer0/23ms3492 KiB
13Wrong answer0/23ms3472 KiB
14Accepted2/23ms3608 KiB
15Wrong answer0/23ms3816 KiB
16Wrong answer0/23ms4024 KiB
17Wrong answer0/23ms4112 KiB
18Wrong answer0/23ms4112 KiB
19Wrong answer0/23ms4108 KiB
20Wrong answer0/23ms4112 KiB
21Wrong answer0/13ms4120 KiB
22Wrong answer0/235ms7368 KiB
23Wrong answer0/237ms7576 KiB
24Wrong answer0/248ms7792 KiB
25Wrong answer0/246ms7652 KiB
26Accepted2/248ms7904 KiB
27Wrong answer0/220ms7864 KiB
28Wrong answer0/237ms7860 KiB
29Wrong answer0/235ms7860 KiB
30Wrong answer0/248ms7864 KiB
31Accepted2/245ms7864 KiB