제출 #38481

#제출 시각아이디문제언어결과실행 시간메모리
3848114kg금 캐기 (IZhO14_divide)C++11
100 / 100
66 ms5408 KiB
#include <stdio.h> #include <algorithm> #define N 100001 #define INF 999999999999999999 #define LL long long #define max2(x,y) (x>y?x:y) using namespace std; struct DNC { int w, g, e; } in[N]; int n, list_len; LL out; pair<LL, LL> d[N]; pair<LL, int> list[N]; int search(long long num) { pair<LL, int> temp = { num,0 }; pair<LL, int> *w = upper_bound(list + 1, list + list_len + 1, temp); return w->second; } int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d %d %d", &in[i].w, &in[i].g, &in[i].e); for (int i = 1; i <= n; i++) d[i] = { d[i - 1].first - (LL)(in[i].w - in[i - 1].w) + (LL)in[i].e, d[i - 1].second + (LL)in[i].g }; list[0] = { -INF,0 }; for (int i = n; i >= 1; i--) if (d[i].first > list[list_len].first) list[++list_len] = { d[i].first,i }; for (int i = 1; i <= n; i++) { int w = search(d[i].first - (LL)in[i].e); out = max2(out, d[w].second - d[i - 1].second); } printf("%lld", out); }

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

divide.cpp: In function 'int main()':
divide.cpp:24:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
divide.cpp:26:50: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d", &in[i].w, &in[i].g, &in[i].e);
                                                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...