-
Notifications
You must be signed in to change notification settings - Fork 1
/
ALIEN.cpp
64 lines (53 loc) · 1.31 KB
/
ALIEN.cpp
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <bits/stdc++.h>
#define ll long
#define get(a) scanf("%ld", &a);
#define rep(n) for( ll i = 0; i < n; i++ )
#define repVector(v) for( typeof(v.begin()) it = v.begin(); it != v.end(); it++ )
#define repSet(s) for( set<ll>::iterator it = s.begin(); it != s.end(); it++ )
#define all(c) c.begin(), c.end()
#define pb push_back
#define max(a,b) ( (a > b) ? a : b )
#define min(a,b) ( (a < b) ? a : b )
#define absol(a) ( ( a >= 0 ) ? a : -a )
#define FOR(i,a,b) for( ll i = a; i <= b; i++ )
#define matrix vector< vector<ll> >
#define MOD 1000000007
#define F first
#define S second
#define mp make_pair
#define INPFILE freopen("input.in","r",stdin)
using namespace std;
pair<ll,ll> cmp( pair<ll,ll> a, pair<ll,ll> b ) {
if( a.S == b.S ) {
if( a.F >= b.F )
return b;
else
return a;
}
else if( a.S > b.S )
return a;
else
return b;
}
int main() {
// INPFILE;
ll t; get(t);
while(t--) {
ll n, m;
get(n); get(m);
pair<ll,ll> ans = mp(0,0);
ll sum = 0, count = 0, ptr = 0;
vector<ll> v;
rep(n) {
ll x; get(x);
v.pb(x);
sum += x;
count++;
while( sum > m && count > 0 )
{ sum -= v[ptr++]; count--; }
if( sum <= m )
ans = cmp( ans, mp( sum, count ) );
}
printf("%ld %ld\n", ans.F, ans.S);
}
}