제출 #1355327

#제출 시각아이디문제언어결과실행 시간메모리
1355327kmath628금 캐기 (IZhO14_divide)C++20
100 / 100
19 ms4340 KiB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100009;
typedef long long ll;
ll x[MAXN], g[MAXN], d[MAXN];
int main(){
    int n,i;
    ll mx=0;
    vector<pair<ll,ll> > a;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%lld %lld %lld",&x[i],&g[i],&d[i]);
        g[i]+=g[i-1];
        d[i]+=d[i-1];
        while(!a.empty() && a.back().first>=x[i]-d[i]) a.pop_back();
        a.push_back({x[i]-d[i],g[i]});
    }
    for(i=1;i<=n;i++){
        auto it=upper_bound(a.begin(),a.end(),make_pair(x[i]-d[i-1],0ll));
        it--;
        mx=max(mx,it->second-g[i-1]);
    }
    printf("%lld\n",mx);
    return 0;
}

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

divide.cpp: In function 'int main()':
divide.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
divide.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         scanf("%lld %lld %lld",&x[i],&g[i],&d[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…