답안 #238855

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
238855 2020-06-13T09:17:55 Z michao Art Exhibition (JOI18_art) C++14
0 / 100
5 ms 384 KB
//              _      _                 
//             (_)    | |                
//    _ __ ___  _  ___| |__   __ _  ___  
//   | '_ ` _ \| |/ __| '_ \ / _` |/ _ \ 
//   | | | | | | | (__| | | | (_| | (_) |
//   |_| |_| |_|_|\___|_| |_|\__,_|\___/ 
//                                       
// 
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/
using namespace std;
const int MAX=500005;
const int inf=1e18+9;
pii tab[MAX];
int pref[MAX];
int32_t main()
{
  BOOST;
  int n;
  cin>>n;
  for (int i=1;i<=n;i++)cin>>tab[i].st>>tab[i].nd;
  sort(tab+1,tab+n+1);
  int ans=0,maxi=0,sum=0;
  for (int i=1;i<=n;i++)
  {
  	sum+=tab[i].nd;
  	pref[i]=sum;
  	int akt=sum-tab[i].st+maxi;
  	ans=max(ans,akt);
  	maxi=max(maxi,tab[i].st-pref[i-1]);
  	//cout<<"TERAZ "<<ans<<" "<<i<<" "<<"\n";
  }
  
  cout<<ans;
  return 0;
}

Compilation message

art.cpp:4:1: warning: multi-line comment [-Wcomment]
 //   | '_ ` _ \| |/ __| '_ \ / _` |/ _ \ 
 ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -