답안 #68432

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
68432 2018-08-17T06:53:03 Z MrTEK 금 캐기 (IZhO14_divide) C++14
0 / 100
6 ms 1276 KB
#include <bits/stdc++.h>
 
using namespace std;
#define mp make_pair
#define pb push_back
#define len(a) (int)a.size()
#define fi first
#define sc second
#define cout maltahsin
#define left ind + ind
#define right ind + ind + 1
#define mid (l + r) / 2 
#define d1(w) cerr<<#w<<":"<<w<<endl;
#define d2(w,c) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<endl;
#define d3(w,c,z) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<" "<<#z<<":"<<z<<endl;
#define FAST_IO ios_base::sync_with_stdio(false);
#define endl '\n'
 
const int maxn = 620;
const long long LINF = 1e18;
const int LOG = 31;
const int INF = 1e9 + 5;
const int N = 1e5 + 5;
const int M = 1e5 + 5;
const int SQ = 350;
const int MOD = 998244353;
 
typedef pair <int,int> pii;

map <long long,int> mpx;

int n,x[N],g[N],d[N];
long long ans,pred[N],preg[N];

int main() {

	scanf("%d",&n);

	for (int i = 1 ; i <= n ; i++) {
		scanf("%d %d %d",&x[i],&g[i],&d[i]);
		pred[i] = pred[i - 1] + d[i];
		preg[i] = preg[i - 1] + g[i];
	}

	for (int i = 1 ; i <= n ; i++) {
		int lst = mpx[pred[i] - x[i]];
		ans = max(ans,1ll * g[i]);
		if (lst) ans = max(preg[i] - preg[lst - 1],ans);
		if (!mpx[pred[i - 1] - x[i]])
		mpx[pred[i - 1] - x[i]] = i;
	}
	printf("%lld\n",ans);

}

Compilation message

divide.cpp: In function 'int main()':
divide.cpp:37:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
divide.cpp:40:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d",&x[i],&g[i],&d[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 248 KB Output is correct
2 Incorrect 2 ms 356 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 432 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 1276 KB Output isn't correct
2 Halted 0 ms 0 KB -