제출 #570563

#제출 시각아이디문제언어결과실행 시간메모리
570563Hanksburger금 캐기 (IZhO14_divide)C++17
100 / 100
35 ms5828 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long ll a[100005], b[100005], c[100005], d[100005], e[100005]; vector<pair<ll, ll> > vec; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n, ans=0; cin >> n; for (ll i=1; i<=n; i++) { ll x, y, num; cin >> a[i] >> x >> y; b[i]=b[i-1]+x; c[i]=c[i-1]+y; num=c[i]-a[i]; while (vec.size() && vec[vec.size()-1].first<=num) vec.pop_back(); vec.push_back({num, i}); } reverse(vec.begin(), vec.end()); for (ll i=0; i<vec.size(); i++) { d[i]=vec[i].first; e[i]=vec[i].second; } for (ll i=1; i<=n; i++) { ll ind=lower_bound(d, d+vec.size(), c[i-1]-a[i])-d; ans=max(ans, b[e[ind]]-b[i-1]); } cout << ans; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

divide.cpp: In function 'int main()':
divide.cpp:25:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for (ll i=0; i<vec.size(); i++)
      |                  ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...