Submission #127334

#TimeUsernameProblemLanguageResultExecution timeMemory
127334josefu_Art Exhibition (JOI18_art)C++14
50 / 100
1055 ms6680 KiB
#define SuC_VaT              Doc_code_ban_khac
#define Nhan_cach_bang_0     Doc_code_ban_khac

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> ii;
typedef pair<ll, ii > iii;

const int kn = 4e5 + 5, N = 1e5+5;

#define x first
#define y second

#define ff(i,n) for(int i=1;i<=n;i++)

int n;
ii cac[kn], lon[kn];
ll pre[kn], ans = 0, mn = -1e17;

int main()
{
	scanf("%d",&n);
	ff(i,n)
	{
		scanf("%lld %lld",&cac[i].x,&cac[i].y);
	}
	sort(cac+1,cac+n+1);
	ff(i,n)
	{
		pre[i]  = pre[i-1] + cac[i].y;
	}
	ff(i,n)
	{
		mn = max(mn, cac[i].x - pre[i-1]);	
		ans = max(ans, pre[i] - cac[i].x + mn);
	}
	printf("%lld",ans);
	
}

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
art.cpp:28:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld",&cac[i].x,&cac[i].y);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...