답안 #40523

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
40523 2018-02-03T18:57:37 Z Pajaraja 금 캐기 (IZhO14_divide) C++14
100 / 100
61 ms 20548 KB
#include <bits/stdc++.h>
using namespace std;
long long x[100007],e[100007],p[100007],g[100007],maxl[100007],pg[100007];
int binarna(int l, int r,long long val)
{
	if(l==r) return l;
	int s=(l+r+1)/2;
	if(maxl[s]>=val) return binarna(s,r,val);
	return binarna(l,s-1,val);
}
int main()
{
	int n;
	long long sol=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d%d%d",&x[i],&g[i],&e[i]);
	for(int i=1;i<=n;i++) p[i]=p[i-1]+e[i];
	for(int i=1;i<=n;i++) pg[i]=pg[i-1]+g[i];
    maxl[n+1]=-1000000000;
	for(int i=n;i>0;i--) maxl[i]=max(maxl[i+1],p[i]-x[i]);
	for(int i=1;i<=n;i++)
	{
		int t=binarna(1,n,p[i-1]-x[i]);
		sol=max(sol,pg[t]-pg[i-1]);
	}
	printf("%lld",sol);
}

Compilation message

divide.cpp: In function 'int main()':
divide.cpp:16:56: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
  for(int i=1;i<=n;i++) scanf("%d%d%d",&x[i],&g[i],&e[i]);
                                                        ^
divide.cpp:16:56: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
divide.cpp:16:56: warning: format '%d' expects argument of type 'int*', but argument 4 has type 'long long int*' [-Wformat=]
divide.cpp:15:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
divide.cpp:16:57: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=n;i++) scanf("%d%d%d",&x[i],&g[i],&e[i]);
                                                         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 1 ms 356 KB Output is correct
3 Correct 2 ms 424 KB Output is correct
4 Correct 2 ms 524 KB Output is correct
5 Correct 1 ms 524 KB Output is correct
6 Correct 2 ms 524 KB Output is correct
7 Correct 1 ms 524 KB Output is correct
8 Correct 1 ms 524 KB Output is correct
9 Correct 1 ms 524 KB Output is correct
10 Correct 1 ms 532 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 620 KB Output is correct
2 Correct 2 ms 624 KB Output is correct
3 Correct 2 ms 624 KB Output is correct
4 Correct 2 ms 624 KB Output is correct
5 Correct 2 ms 624 KB Output is correct
6 Correct 2 ms 624 KB Output is correct
7 Correct 2 ms 656 KB Output is correct
8 Correct 2 ms 820 KB Output is correct
9 Correct 2 ms 844 KB Output is correct
10 Correct 2 ms 884 KB Output is correct
11 Correct 4 ms 1064 KB Output is correct
12 Correct 4 ms 1316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1316 KB Output is correct
2 Correct 5 ms 1444 KB Output is correct
3 Correct 6 ms 1444 KB Output is correct
4 Correct 25 ms 3364 KB Output is correct
5 Correct 30 ms 3364 KB Output is correct
6 Correct 61 ms 8612 KB Output is correct
7 Correct 45 ms 10456 KB Output is correct
8 Correct 45 ms 12428 KB Output is correct
9 Correct 43 ms 14208 KB Output is correct
10 Correct 47 ms 15936 KB Output is correct
11 Correct 55 ms 18120 KB Output is correct
12 Correct 57 ms 20548 KB Output is correct