#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;
ll n,m;
vl v[2];
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> m;
v[0] = v[1] = {0};
F0R(i,n) {
ll x; cin >> x;
F0Rd(j,sz(v[i&1])) v[i&1].pb(v[i&1][j]+x);
}
F0R(i,2) sort(all(v[i]));
int i1 = sz(v[1])-1;
ll ans = 0;
F0R(i0,sz(v[0])) {
while (i1 >= 0 && v[0][i0]+v[1][i1] > m) i1 --;
ans += i1+1;
}
cout << ans;
}
// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
616 KB |
Output is correct |
2 |
Correct |
2 ms |
616 KB |
Output is correct |
3 |
Correct |
2 ms |
656 KB |
Output is correct |
4 |
Correct |
2 ms |
720 KB |
Output is correct |
5 |
Correct |
2 ms |
760 KB |
Output is correct |
6 |
Correct |
3 ms |
760 KB |
Output is correct |
7 |
Correct |
3 ms |
764 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
768 KB |
Output is correct |
2 |
Correct |
2 ms |
772 KB |
Output is correct |
3 |
Correct |
2 ms |
904 KB |
Output is correct |
4 |
Correct |
2 ms |
904 KB |
Output is correct |
5 |
Correct |
3 ms |
904 KB |
Output is correct |
6 |
Correct |
2 ms |
904 KB |
Output is correct |
7 |
Correct |
2 ms |
904 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
912 KB |
Output is correct |
2 |
Correct |
3 ms |
912 KB |
Output is correct |
3 |
Correct |
3 ms |
912 KB |
Output is correct |
4 |
Correct |
2 ms |
912 KB |
Output is correct |
5 |
Correct |
2 ms |
1016 KB |
Output is correct |
6 |
Correct |
2 ms |
1016 KB |
Output is correct |
7 |
Correct |
3 ms |
1016 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
2728 KB |
Output is correct |
2 |
Correct |
59 ms |
5280 KB |
Output is correct |
3 |
Correct |
245 ms |
17536 KB |
Output is correct |
4 |
Correct |
59 ms |
17536 KB |
Output is correct |
5 |
Correct |
10 ms |
17536 KB |
Output is correct |
6 |
Correct |
8 ms |
17536 KB |
Output is correct |
7 |
Correct |
14 ms |
17536 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
17536 KB |
Output is correct |
2 |
Correct |
22 ms |
17536 KB |
Output is correct |
3 |
Correct |
91 ms |
17536 KB |
Output is correct |
4 |
Correct |
2 ms |
17536 KB |
Output is correct |
5 |
Correct |
5 ms |
17536 KB |
Output is correct |
6 |
Correct |
14 ms |
17536 KB |
Output is correct |
7 |
Correct |
44 ms |
17536 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
44 ms |
17536 KB |
Output is correct |
2 |
Correct |
85 ms |
17536 KB |
Output is correct |
3 |
Correct |
94 ms |
17536 KB |
Output is correct |
4 |
Correct |
2 ms |
17536 KB |
Output is correct |
5 |
Correct |
45 ms |
17536 KB |
Output is correct |
6 |
Correct |
189 ms |
17572 KB |
Output is correct |
7 |
Correct |
91 ms |
17572 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
192 ms |
17572 KB |
Output is correct |
2 |
Correct |
36 ms |
17572 KB |
Output is correct |
3 |
Correct |
9 ms |
17572 KB |
Output is correct |
4 |
Correct |
3 ms |
17572 KB |
Output is correct |
5 |
Correct |
7 ms |
17572 KB |
Output is correct |
6 |
Correct |
190 ms |
17572 KB |
Output is correct |
7 |
Correct |
16 ms |
17572 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
17572 KB |
Output is correct |
2 |
Correct |
59 ms |
17572 KB |
Output is correct |
3 |
Correct |
9 ms |
17572 KB |
Output is correct |
4 |
Correct |
9 ms |
17572 KB |
Output is correct |
5 |
Correct |
52 ms |
17572 KB |
Output is correct |
6 |
Correct |
22 ms |
17572 KB |
Output is correct |
7 |
Correct |
250 ms |
17820 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
249 ms |
17820 KB |
Output is correct |
2 |
Correct |
23 ms |
17820 KB |
Output is correct |
3 |
Correct |
9 ms |
17820 KB |
Output is correct |
4 |
Correct |
259 ms |
17820 KB |
Output is correct |
5 |
Correct |
84 ms |
17820 KB |
Output is correct |
6 |
Correct |
14 ms |
17820 KB |
Output is correct |
7 |
Correct |
27 ms |
17820 KB |
Output is correct |