# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1050016 | 2024-08-09T06:53:44 Z | vjudge1 | Art Exhibition (JOI18_art) | C++17 | 1 ms | 2396 KB |
#include <bits/stdc++.h> using namespace std; //typedef long long ll; ///typedef unsigned long long ull; //typedef pair<long long,long long> pl; #define all(s) s.begin(),s.end() #define F first #define S second #define sz(a) a.size() #define int long long typedef pair<int,int> pi; //const ll mod = 998244353; //const ll mod1 = 1e9+7; //const ll INF = 1e18; const int N = 100200; const int inf = 1e18+200; int n; pi a[N*5]; int p[N*5]; pi b[N*5]; void solve() { cin>>n; for(int i=1;i<=n;++i) { cin>>a[i].F>>a[i].S; } sort(a+1,a+1+n); for(int i=1;i<=n;++i) { p[i]=p[i-1]+a[i].S; } int mn=-inf; int mx=-inf; int ans=0; int mxi; int mni; for(int i=1;i<=n;++i) { b[i].F=p[i]-a[i].F; b[i].S=a[i].F-p[i-1]; } for(int i=1;i<=n;++i) { if(mx<=b[i].F) { mx=b[i].F; mxi=i; } } for(int i=1;i<=n;++i) { if(mn<=b[i].S) { mn=b[i].S; mni=i; } } if(mx>=mn) { for(int i=1;i<=mxi;++i) { mn=max(mn,b[i].S); } cout<<mx+mn; } else { for(int i=mni;i<=n;++i) { mx=max(mx,b[i].F); } cout<<mx+mn; } } signed main() { ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); int T=1; //cin>>T; while(T--) { solve(); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2396 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2396 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2396 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2396 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |