Submission #1049790

# Submission time Handle Problem Language Result Execution time Memory
1049790 2024-08-09T05:06:08 Z vjudge1 Art Exhibition (JOI18_art) C++17
0 / 100
1 ms 4444 KB
#include <iostream>
#include <fstream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <numeric>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <complex>
#include <climits>
#include <random>
using namespace std;

#define ll long long
#define pb push_back
#define ull unsigned long long
#define F first
#define S second
#define all(v) v.begin(), v.end() 
#define rall(x) x.rbegin(), (x).rend()

const ll mod = 1e9 + 7;
const int block = 450;
const ll LINF = 1e16;
const int INF = 1e8;

ll add(ll a, ll b){
    ll x = a + b;
    if(x < 0) x += mod;
    if(x >= mod) x -= mod;
    return x;
}

ll mul(ll a, ll b){
    return (a * b) % mod;
}

ll sub(ll x, ll y){
    return add(x, -y);
}   

ll binpow(ll a, ll b) {
    ll res = 1LL;
    while (b > 0) {
        if (b & 1)
            res = (res * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}

int n;
ll a[500005]; 
ll b[500005];
ll dp[500005];
pair<ll, ll> kek[500005];

void solve(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i] >> b[i];
        kek[i] = {a[i], b[i]};
    }
    sort(kek + 1, kek + 1 + n);
    for(int i = 1; i <= n; i++){
        a[i] = kek[i].F;
        b[i] = kek[i].S;
    }
    for(int i = 1; i <= n; i++){
        dp[i] = max(dp[i - 1] + b[i], a[i] + b[i]);
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        ll x = (b[i] - a[i]) + dp[i - 1];
        ans = max(ans, x);
    }
    cout << ans;
}  
 
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    int xach = 1; 
    //cin >> xach;
    while(xach--) solve();
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -