제출 #1266949

#제출 시각아이디문제언어결과실행 시간메모리
1266949michael12Art Exhibition (JOI18_art)C++20
0 / 100
0 ms320 KiB
#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<long long, int> pii;
int main(){
    // int n,m;
    // int dx[4] = {0, 0, -1, 1};
    // int dy[4] = {1, -1, 0, 0};
    // cin >> n;
    // vector<int> a(n);
    // for(int i = 0; i < n; i++){
    //   cin >> a[i];
    // }
    // sort(a.begin(), a.end());
    // set<int> st;
    // vector<int> nn;
    // for(int i = 0; i < n - 2; i++){  
    //   for(int j = i + 1; j < n - 1; j++){
    //     nn.push_back(a[i] + a[j]);
       
    // }
    //  }
      
    //  int ans = 0;
    // for(int i = 0; i < nn.size(); i++){
    //   auto it = upper_bound(a.begin(), a.end(), nn[i]) - a.begin();
    //   if(it < n){
    //      ans += n - it;
    //   }
      

    // }
    // cout << ans;
    int n;
    cin >> n;
    pair<int, int> a[2 * n];
    for(int i = 0; i < n; i++){
      cin >> a[i].ff >> a[i].ss; 
    }
    sort(a, a + n);
    int dp[1000];
    dp[0] = a[0].ss;
    for(int i = 1; i < n; i++){
      dp[i] = max(a[i].ss, dp[i - 1] + a[i - 1].ff + a[i].ss - a[i].ff);
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
      ans = max(ans, dp[i]);
    }
    cout << ans;
    

  
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...