답안 #945547

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
945547 2024-03-14T04:26:51 Z vjudge1 Art Exhibition (JOI18_art) C++17
10 / 100
5 ms 600 KB
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("Ofast,unroll-loops,fast-math,O3")

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
#include <unordered_map>
#define ll long long
#define int long long
#define all(v) v.begin(), v.end()
#define nl '\n'
#define pb push_back
#define sz(s) (int)(s).size()
#define f first
#define s second
using namespace std;
const ll N = 1e6 + 50, MX = 1e18;
void solve(){
    ll n;
    cin >> n;
    ll a[n + 1], b[n + 1];
    for(int i = 1; i <= n; i++){
        cin >> a[i] >> b[i];
    }
    ll ans = 0;
    for(ll mask = 0; mask < (1 << n); mask++){
        ll mx=0, mn=MX;
        ll sum = 0;
        for(int i = 0; i < n; i++){
            if((mask >> i)&1){
                mx = max(mx, a[i+1]);
                mn = min(mn, a[i+1]);
                sum += b[i+1];
            }
        }
        if(mn == MX){
            continue;
        }
        ans = max(sum - (mx - mn), ans);
    }
    cout << ans << nl;
}
signed main(){
    //freopen("lca.in", "r", stdin);
    //freopen("lca.out", "w", stdout);
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll ql=1;
    //cin >> ql;
    //tst++;
    while(ql--){
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 348 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 4 ms 348 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
6 Correct 4 ms 348 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
8 Correct 4 ms 600 KB Output is correct
9 Correct 4 ms 348 KB Output is correct
10 Correct 4 ms 456 KB Output is correct
11 Correct 4 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 348 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 4 ms 348 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
6 Correct 4 ms 348 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
8 Correct 4 ms 600 KB Output is correct
9 Correct 4 ms 348 KB Output is correct
10 Correct 4 ms 456 KB Output is correct
11 Correct 4 ms 348 KB Output is correct
12 Incorrect 2 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 348 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 4 ms 348 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
6 Correct 4 ms 348 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
8 Correct 4 ms 600 KB Output is correct
9 Correct 4 ms 348 KB Output is correct
10 Correct 4 ms 456 KB Output is correct
11 Correct 4 ms 348 KB Output is correct
12 Incorrect 2 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 348 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 4 ms 348 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
6 Correct 4 ms 348 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
8 Correct 4 ms 600 KB Output is correct
9 Correct 4 ms 348 KB Output is correct
10 Correct 4 ms 456 KB Output is correct
11 Correct 4 ms 348 KB Output is correct
12 Incorrect 2 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -