답안 #96241

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
96241 2019-02-07T12:38:43 Z pamaj Art Exhibition (JOI18_art) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>
using namespace std;
typedef uint64_t ll;
const int maxn = 5e5 + 10;;

ll n, pref[maxn];
vector<pair<ll, ll>> v;

int main()
{
	ios::sync_with_stdio(false), cin.tie(nullptr);

	cin >> n;
	for(int i = 0; i < n; i++)
	{
		ll a, b;
		cin >> a >> b;
		v.push_back({a, b});
	}

	sort(v.begin(), v.end());

	// for(int i = 0; i < n; i++)
	// {
	// 	if(!i) pref[i] = v[i].second;
	// 	else
	// 	{
	// 		pref[i] = pref[i - 1] + v[i].second;
	// 	}
	// }

	ll ans = 0;

	for(int i = 0; i < n - 1; i++)
	{
		ll sum = v[i].second;

		for(int j = i + 1; j < n; j++)
		{
			sum += v[j].second;
			ans = max(ans, sum - (v[j].first- v[i].first));
		}
	}

	cout << ans << "\n";


}

Compilation message

art.cpp: In function 'int main()':
art.cpp:14:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < n; i++)
                 ~~^~~
art.cpp:34:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < n - 1; i++)
                 ~~^~~~~~~
art.cpp:38:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j = i + 1; j < n; j++)
                      ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -