99222024-03-18 16:58:53CWMSzitakötő (50 pont)cpp17Wrong answer 8/5048ms7464 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-k) - (n - i + 1);
		}
	}
	if (k == n - 1) twoPower++;
	cout << twopow(twoPower + twoPower2);
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base8/50
1Accepted0/03ms1684 KiB
2Wrong answer0/048ms4972 KiB
3Wrong answer0/13ms2140 KiB
4Accepted1/13ms2368 KiB
5Wrong answer0/13ms2408 KiB
6Accepted1/13ms2428 KiB
7Wrong answer0/13ms2552 KiB
8Wrong answer0/13ms2556 KiB
9Wrong answer0/13ms2752 KiB
10Wrong answer0/23ms2984 KiB
11Wrong answer0/22ms3076 KiB
12Wrong answer0/23ms3196 KiB
13Wrong answer0/23ms3428 KiB
14Accepted2/23ms3636 KiB
15Wrong answer0/23ms3868 KiB
16Wrong answer0/23ms3912 KiB
17Wrong answer0/23ms3844 KiB
18Wrong answer0/23ms3968 KiB
19Wrong answer0/23ms4132 KiB
20Wrong answer0/23ms3976 KiB
21Wrong answer0/13ms3984 KiB
22Wrong answer0/235ms6972 KiB
23Wrong answer0/237ms6880 KiB
24Wrong answer0/248ms6876 KiB
25Wrong answer0/248ms6876 KiB
26Accepted2/248ms6876 KiB
27Wrong answer0/220ms6956 KiB
28Wrong answer0/237ms7132 KiB
29Wrong answer0/235ms7464 KiB
30Wrong answer0/248ms7416 KiB
31Accepted2/245ms7380 KiB