제출 #166390

#제출 시각아이디문제언어결과실행 시간메모리
166390abil금 캐기 (IZhO14_divide)C++14
100 / 100
73 ms9064 KiB
#include <bits/stdc++.h>
 
#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define all(s) s.begin(),s.end()
#define int long long
 
using namespace std;
 
const int N = (1e6 + 12);
const int mod = (1e9 + 7);
const int INF = (1e15 + 9);
 
int x[N], g[N], c[N], pr[N], prg[N], mx[N];
vector<pair<int,int > > vec;
main()
{
	int n;
	scanf("%lld", &n);
	for(int i = 1;i <= n; i++){
		scanf("%lld%lld%lld", &x[i], &g[i], &c[i]);
		pr[i] = pr[i - 1] + c[i];
		vec.pb({x[i] - pr[i], i});
		prg[i] = prg[i - 1] + g[i];
	}
	sort(all(vec));
	for(int i = 0;i < vec.size(); i++){
		mx[i] = max(vec[i].sc, mx[i - 1]);
	}
	int ans = 0;
	for(int i = 1;i <= n; i++){
		int pos = upper_bound(all(vec), make_pair(x[i] - pr[i - 1], INF)) - vec.begin();
		ans = max(ans, prg[mx[pos - 1]] - prg[i - 1]);
	}
	cout << ans;
}

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

divide.cpp:18:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
divide.cpp: In function 'int main()':
divide.cpp:29:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0;i < vec.size(); i++){
                ~~^~~~~~~~~~~~
divide.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &n);
  ~~~~~^~~~~~~~~~~~
divide.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld%lld", &x[i], &g[i], &c[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...