답안 #206153

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
206153 2020-03-02T13:27:16 Z SoGood Art Exhibition (JOI18_art) C++17
0 / 100
5 ms 376 KB
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)

using namespace std;


#define int ll
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 5e5 + 11;
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

int n;
pii a[N];
main() {
  cin>>n;
  fo(i,1,n,1) cin>>a[i].F>>a[i].S;
  sort(a+1,a+n+1, greater<pii>());
  int r = 0,sum=0,ans=0;
  fo(l,1,n,1) {
    if (r<l) r=l,sum=a[l].S;
    while (r + 1 <= n) {
      int val1=sum-a[l].F+a[r].F;
      int val2=sum+a[r+1].S-a[l].F+a[r+1].F;
      if (val2 >= val1) ++r,sum+=a[r].S;
      else break;
    }
    chmax(ans,sum-a[l].F+a[r].F);
    sum-=a[l].F;
  }
  cout<<ans;
  return 0;
}

Compilation message

art.cpp:24:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Incorrect 5 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Incorrect 5 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Incorrect 5 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Incorrect 5 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -