Submission #1040383

#TimeUsernameProblemLanguageResultExecution timeMemory
1040383vjudge1Divide and conquer (IZhO14_divide)C++17
48 / 100
1036 ms2912 KiB
#include <bits/stdc++.h> #define Y8o "Divide and conquer" #define maxn (int) 1e5 + 5 #define ll long long #define pii pair<ll, ll> #define gb(i, j) ((i >> j) & 1) #define all(x) x.begin(), x.end() #define _left id * 2, l, mid #define _right id * 2 + 1, mid + 1, r //#define f first //#define s second using namespace std; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll GetRandom(ll l, ll r) { return uniform_int_distribution<ll> (l, r) (rng); } void iof() { if(fopen(Y8o".inp", "r")) { freopen(Y8o".inp", "r", stdin); // freopen(Y8o".out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(NULL), cout.tie(NULL); } void ctime() { cerr << "\n" << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n"; } int n; struct dl { int td, g, e; } a[maxn]; ll se[maxn], sg[maxn]; void solve() { cin >> n; for(int i = 1; i <= n; i ++) { cin >> a[i].td >> a[i].g >> a[i].e; se[i] = se[i - 1] + a[i].e, sg[i] = sg[i - 1] + a[i].g; } ll ans = 0; for(int i = 1; i <= n; i ++) { for(int j = i; j <= n; j ++) { if(a[j].td - a[i].td <= se[j] - se[i - 1]) { ans = max(ans, sg[j] - sg[i - 1]); } } } cout << ans; } int main() { iof(); int nTest = 1; // cin >> nTest; while(nTest --) { solve(); } ctime(); return 0; }

Compilation message (stderr)

divide.cpp: In function 'void iof()':
divide.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen(Y8o".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...