#include<iostream>
#include<cstring>
#define endl '\n'
using namespace std;
long long m[100003][4],dp[100003],used[5002],maxi,n;
void mine(long long ind,long long mg,long long en)
{
long long i;
//if(used[ind])return mg;
long long p=0;
maxi=max(maxi,mg);
for(i=ind-1;i>=0;i--)
{
if(used[i])continue;
if(m[ind][0]-m[i][0]>en)break;
used[i]=1;mine(i,mg+m[i][1],m[i][2]);
used[i]=0;
}
for(i=ind+1;i<n;i++)
{
if(used[i])continue;
if(m[i][0]-m[ind][0]>en)break;
used[i]=1;mine(i,mg+m[i][1],m[i][2]);
used[i]=0;
}
return;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long i,mm=0;
cin>>n;
for(i=0;i<n;i++)
{
cin>>m[i][0]>>m[i][1]>>m[i][2];
}
for(i=0;i<n;i++)
{
used[i]=1;
maxi=0;
mine(i,m[i][1],m[i][2]);
// cout<<maxi<<endl;
memset(used,0,sizeof(used));
}
cout<<maxi<<endl;
}
Compilation message
divide.cpp: In function 'void mine(long long int, long long int, long long int)':
divide.cpp:10:15: warning: unused variable 'p' [-Wunused-variable]
10 | long long p=0;
| ^
divide.cpp: In function 'int main()':
divide.cpp:33:17: warning: unused variable 'mm' [-Wunused-variable]
33 | long long i,mm=0;
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |