-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11089.cpp
More file actions
44 lines (42 loc) · 919 Bytes
/
11089.cpp
File metadata and controls
44 lines (42 loc) · 919 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <limits.h>
#include <memory.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
using namespace std;
#define ll long long
int a[2][41];
ll dp[2][801][801];
const int w = 400;
bool tog;
int main() {
int n;
int as = 0, _as = 0, bs = 0, _bs = 0;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d %d", &a[0][i], &a[1][i]);
if (a[0][i] >= 0)
as += a[0][i];
else
_as -= a[0][i];
if (a[1][i] >= 0)
bs += a[1][i];
else
_bs -= a[1][i];
}
dp[tog][w][w] = 1;
for (int k = 0; k < n; k++) {
tog = !tog;
memset(dp[tog], 0, sizeof(dp[tog]));
for (int i = w + as; i >= w - _as; i--) {
for (int j = w + bs; j >= w - _bs; j--) {
dp[tog][i][j] += dp[!tog][i - a[0][k]][j - a[1][k]] + dp[!tog][i][j];
}
}
}
printf("%lld\n", dp[tog][w][w] - 1);
}