답안 #444881

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
444881 2021-07-15T17:36:02 Z JovanB 금 캐기 (IZhO14_divide) C++17
100 / 100
43 ms 7324 KB
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
ll g[100005];
ll x[100005];
ll d[100005];
ll xx[100005];
 
int main(){
    ios_base::sync_with_stdio(false);
 
    int n;
    cin >> n;
    vector <pair <ll, int>> tren;
    ll sum = 0;
    for(int i=1; i<=n; i++){
        cin >> xx[i] >> g[i] >> d[i];
        x[i] = xx[i]-xx[1];
        g[i] += g[i-1];
        d[i] += d[i-1];
        sum = max(sum, g[i]-g[i-1]);
        int l=0, r=tren.size()-1, j=i;
        while(l <= r){
            int mid = (l+r)/2;
            if(tren[mid].first-x[i]+d[i] >= 0){
                r = mid-1;
                j = mid;
            }
            else l = mid+1;
        }
        if(j < tren.size()) sum = max(sum, g[i]-g[tren[j].second-1]);
        if(tren.empty() || tren.back().first < x[i]-d[i-1]) tren.push_back({x[i]-d[i-1], i});
    }
    cout << sum << "\n";
    return 0;
}

Compilation message

divide.cpp: In function 'int main()':
divide.cpp:33:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         if(j < tren.size()) sum = max(sum, g[i]-g[tren[j].second-1]);
      |            ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 252 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 252 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 320 KB Output is correct
14 Correct 1 ms 304 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 352 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 460 KB Output is correct
23 Correct 3 ms 708 KB Output is correct
24 Correct 3 ms 692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 252 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 320 KB Output is correct
14 Correct 1 ms 304 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 352 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 460 KB Output is correct
23 Correct 3 ms 708 KB Output is correct
24 Correct 3 ms 692 KB Output is correct
25 Correct 2 ms 460 KB Output is correct
26 Correct 3 ms 716 KB Output is correct
27 Correct 4 ms 716 KB Output is correct
28 Correct 19 ms 2892 KB Output is correct
29 Correct 20 ms 3172 KB Output is correct
30 Correct 40 ms 6216 KB Output is correct
31 Correct 34 ms 5136 KB Output is correct
32 Correct 35 ms 5188 KB Output is correct
33 Correct 35 ms 4952 KB Output is correct
34 Correct 39 ms 5888 KB Output is correct
35 Correct 39 ms 7172 KB Output is correct
36 Correct 43 ms 7324 KB Output is correct