QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#372382#1820. Contest Constructionchuchu#WA 1ms3976kbC++141.4kb2024-03-31 12:29:252024-03-31 12:29:26

Judging History

你现在查看的是最新测评结果

  • [2024-03-31 12:29:26]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3976kb
  • [2024-03-31 12:29:25]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define FINISH cerr << "FINISH" << endl;
#define debug(x) cerr << #x << " == " << x << endl
#define el '\n'
#define fir first
#define sec second
typedef long long ll;
typedef pair<int, int> PII;
const int mod = 1000000007;
const int inf = 0x3f3f3f3f;
const int N = 200020;
int dp[55][20][55];
void solve()
{
	int n, kk;
	cin >> n >> kk;
	vector<int> a(n + 1, 0);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j < i; j++) {
			dp[i][2][j] = 1;
		}
	}
	sort(next(a.begin()), a.end());
	for (int i = 3; i <= n; i++) {
		for (int j = 3; j <= min(kk, i); j++) {
			// debug(j);
			for (int k = 1; k < i; k++) {
				// cout << "IJK" << i << " " << j << " " << k << endl;
				for (int l = 1; l < k; l++) {
					if (a[l] + a[k] >= a[i]) {
						// cout << "FIND  " << l << " " << k << " " << i <<
						// endl;
						dp[i][j][k] += dp[k][j - 1][l];
					}
				}
			}
			// cout << endl;
		}
	}
	/*for (int i = 3; i <= n; i++) {
		for (int j = 1; j < i; j++) {
			for (int k = 1; k < j; k++) {
				if(a[k]+a[j])
			}
		}
	}*/
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j < i; j++) {
			ans += dp[i][kk][j];
		}
	}
	cout << ans << endl;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin >> T;
	while (T--) {
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3800kb

input:

5 4
2
1
4
3
5

output:

4

result:

ok answer is '4'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3624kb

input:

8 5
1
2
3
5
8
13
21
34

output:

4

result:

ok answer is '4'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3760kb

input:

50 18
543
654
76
654
45
89879
5465
52534
65
76
987
54
342
76
897
98
78
765
653
763
532
654
543
432
653
754
876
9786
653
836
346
76
235
765
2543
765
443
76
7654
25
65
765
543
543
7654
54
3
76
43
54

output:

10783193

result:

ok answer is '10783193'

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3976kb

input:

50 18
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19
19

output:

-49758268865

result:

wrong answer expected '18053528883775', found '-49758268865'