Submission #758357

#TimeUsernameProblemLanguageResultExecution timeMemory
758357KN200711Divide and conquer (IZhO14_divide)C++14
17 / 100
1 ms304 KiB
# include <bits/stdc++.h> # define ll long long # define fi first # define se second using namespace std; int main() { int N; scanf("%d", &N); vector<int> x(N), y(N), z(N); for(int i=0;i<N;i++) scanf("%d %d %d", &x[i], &y[i], &z[i]); ll pref = 0ll; vector< pair<ll, ll> > as; as.clear(); ll ans = 0ll, nw = 0ll; for(int i=0;i<N;i++) { if(as.size() == 0 || as.back().fi > pref - 1ll * x[i]) as.push_back(make_pair(-pref + 1ll * x[i], nw)); nw += y[i]; pref += z[i]; ll ck = pref - x[i]; // cout<<ck<<endl; int P = lower_bound(as.begin(), as.end(), make_pair(-ck, 0ll)) - as.begin(); ans = max(ans, nw - as[P].se); } printf("%lld\n", ans); return 0; }

Compilation message (stderr)

divide.cpp: In function 'int main()':
divide.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  scanf("%d", &N);
      |  ~~~~~^~~~~~~~~~
divide.cpp:12:28: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  for(int i=0;i<N;i++) scanf("%d %d %d", &x[i], &y[i], &z[i]);
      |                       ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...