제출 #1173215

#제출 시각아이디문제언어결과실행 시간메모리
1173215DangKhoizzzzDivide and conquer (IZhO14_divide)C++17
48 / 100
1095 ms1604 KiB
#include <bits/stdc++.h> #define int long long #define pii pair <int , int> #define fi first #define se second #define arr3 array <int , 3> using namespace std; const int INF = 1e9; const int maxn = 5e5 + 7; // brute để hiểu đề int n , ps[maxn]; arr3 a[maxn]; void solve() { cin >> n; for(int i = 1; i <= n; i++) { cin >> a[i][0] >> a[i][1] >> a[i][2]; } sort(a+1 , a+n+1); int ans = 0; for(int i = 1; i <= n; i++) { int sumg = 0; int sumd = 0; for(int j = i; j >= 1; j--) { int len = a[i][0] - a[j][0] + 1; sumg += a[j][1]; sumd += a[j][2]; if(sumd >= len) { ans = max(ans , sumg); } } } cout << ans << '\n'; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...