hiho week 139 register

Ended

Participants:518

Verdict:Accepted
Score:100 / 100
Submitted:2017-02-28 21:22:14

Lang:G++

Edit
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
#include <bits/stdc++.h>
using namespace std;
int Q,N;
int b[55];
float a[55];
int sum,Max=-1;
void solve(float s,int n,int seq,int l){
    if(n>3) return;
    if(s==int(s))
    if(int(s)%5==0)
    {
        if(l>Max) Max=l;
    }
    for(int i=seq;i<N;i++){
        solve(a[i]+s,n+1,i+1,l+b[i]);
    }
}
int main(){
    cin>>Q;
    while(Q--){
        cin>>N;
        Max=-1;
        for(int i=0;i<N;i++){
            cin>> a[i]>>b[i];
            }
        solve(0,0,0,0); 
        cout<<Max<<endl;
    }
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX