-
Notifications
You must be signed in to change notification settings - Fork 1
/
compensation.c
53 lines (53 loc) · 1.25 KB
/
compensation.c
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
#include<stdio.h>
inline int fastinput()
{
int inp=0;char c=0;
c=getchar_unlocked();
while(c>='0'&&c<='9')
{
inp=inp*10+c-'0';
c=getchar_unlocked();
}
return inp;
}
inline long long fastinputl()
{
long long inp=0;char c=0;
c=getchar_unlocked();
while(c>='0'&&c<='9')
{
inp=inp*10+c-'0';
c=getchar_unlocked();
}
return inp;
}
int main()
{
int t,n;
t=fastinput();
while(t--)
{
n=fastinput();
int c[49][49]={0},i,s,e,temp,profit[49]={0},j;
for(i=0;i<n;i++)
{
s=fastinput();
e=fastinput();
temp=fastinput();
if(temp>c[s][e])
c[s][e]=temp;
}
for(i=1;i<49;i++)
{
temp=0;
for(j=0;j<i;j++)
{
if(c[j][i]+profit[j]>temp)
temp=c[j][i]+profit[j];
}
profit[i]=temp;
}
printf("%d\n",profit[48]);
}
return 0;
}