답안 #570562

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
570562 2022-05-30T13:29:23 Z Hanksburger 금 캐기 (IZhO14_divide) C++17
100 / 100
45 ms 8148 KB
#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 (int i=0; i<vec.size(); i++)
    {
        d[i]=vec[i].first;
        e[i]=vec[i].second;
    }
    for (ll i=1; i<=n; i++)
    {
        int 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;
}

Compilation message

divide.cpp: In function 'int main()':
divide.cpp:25:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for (int i=0; i<vec.size(); i++)
      |                   ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 388 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 372 KB Output is correct
22 Correct 1 ms 464 KB Output is correct
23 Correct 3 ms 852 KB Output is correct
24 Correct 3 ms 864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 388 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 372 KB Output is correct
22 Correct 1 ms 464 KB Output is correct
23 Correct 3 ms 852 KB Output is correct
24 Correct 3 ms 864 KB Output is correct
25 Correct 2 ms 468 KB Output is correct
26 Correct 3 ms 704 KB Output is correct
27 Correct 4 ms 724 KB Output is correct
28 Correct 14 ms 2436 KB Output is correct
29 Correct 15 ms 2764 KB Output is correct
30 Correct 33 ms 5452 KB Output is correct
31 Correct 26 ms 4300 KB Output is correct
32 Correct 25 ms 4392 KB Output is correct
33 Correct 33 ms 4260 KB Output is correct
34 Correct 33 ms 5888 KB Output is correct
35 Correct 42 ms 8072 KB Output is correct
36 Correct 45 ms 8148 KB Output is correct