답안 #972297

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
972297 2024-04-30T10:29:53 Z vjudge1 Art Exhibition (JOI18_art) C++17
10 / 100
13 ms 468 KB
#include <bits/stdc++.h>

#define pb push_back
#define int long long
#define F first
#define S second
#define clr clear()
#define sz size()
#define str string
#define pf push_front
#define endl "\n"
#define M 5005
#define N 200005
#define set(a) fixed << setprecision(a)
#define all(s) s.begin(),s.end()
#define ppb pop_back()
#define ppf pop_front()
#define ios_base ios_base::sync_with_stdio(false); cin.tie(NULL);
 
using namespace std;
  
int T = 1;

const int inf = 1e18+7;

void freopen(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout);}
int lcm(int a,int b){return (a / __gcd(a, b)) * b;};
int binpow(int a,int n){if(n==0)return 1;else if(n%2==1)return binpow(a,n-1)*a;else{int b = binpow(a,n/2);return b*b;}}
int nceil(int a,int b){return (a+b-1)/b;};
bool isbig(char x){return x >= 65 && x <= 90;}
bool issmall(char x){return x >= 97 && x <= 122;}

struct edge{
    int a,b;
} p[N];
void solve(){
    int n;
    cin >> n;
    for(int i=0;i < n;i++){
        cin >> p[i].a >> p[i].b;
    }
    int maxx = -inf;
    for(int i=1;i < (1 << n);i++){
        vector <edge> v;
        for(int j=0;j < n;j++){
            if(i & (1 << j)){
                // cout << "j = " << j << " ";
                v.pb(p[j]);
            }
        }
        int sum = 0,mn = inf,mx = 0;
        for(int j=0;j < v.sz;j++){
            mx = max(mx,v[j].a);
            sum+=v[j].b;
            mn = min(mn,v[j].a);
            // if(i==5){
            //     cout << endl;
            //     cout << v[j].a << " " << v[j].b;
            // }
        }
        maxx = max(sum-mx+mn,maxx);
        // cout << "i = " << i << " maxx = " << maxx  << " sum = " << sum << " mn = " << mn << " mx = " << mx << endl;
    }
    cout << maxx;
}

main() {
   ios_base;
//   cin >> T;//ne zabyd steret
//   freopen("");
    while(T--){
        solve();
    }
}

Compilation message

art.cpp: In function 'void solve()':
art.cpp:52:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<edge>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |         for(int j=0;j < v.sz;j++){
      |                       ^
art.cpp: At global scope:
art.cpp:67:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   67 | main() {
      | ^~~~
art.cpp: In function 'void freopen(std::string)':
art.cpp:26:33: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 | void freopen(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout);}
      |                          ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
art.cpp:26:75: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 | void freopen(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout);}
      |                                                                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 348 KB Output is correct
2 Correct 10 ms 468 KB Output is correct
3 Correct 10 ms 348 KB Output is correct
4 Correct 11 ms 348 KB Output is correct
5 Correct 10 ms 460 KB Output is correct
6 Correct 11 ms 344 KB Output is correct
7 Correct 13 ms 344 KB Output is correct
8 Correct 11 ms 348 KB Output is correct
9 Correct 11 ms 344 KB Output is correct
10 Correct 11 ms 348 KB Output is correct
11 Correct 11 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 348 KB Output is correct
2 Correct 10 ms 468 KB Output is correct
3 Correct 10 ms 348 KB Output is correct
4 Correct 11 ms 348 KB Output is correct
5 Correct 10 ms 460 KB Output is correct
6 Correct 11 ms 344 KB Output is correct
7 Correct 13 ms 344 KB Output is correct
8 Correct 11 ms 348 KB Output is correct
9 Correct 11 ms 344 KB Output is correct
10 Correct 11 ms 348 KB Output is correct
11 Correct 11 ms 460 KB Output is correct
12 Incorrect 4 ms 344 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 348 KB Output is correct
2 Correct 10 ms 468 KB Output is correct
3 Correct 10 ms 348 KB Output is correct
4 Correct 11 ms 348 KB Output is correct
5 Correct 10 ms 460 KB Output is correct
6 Correct 11 ms 344 KB Output is correct
7 Correct 13 ms 344 KB Output is correct
8 Correct 11 ms 348 KB Output is correct
9 Correct 11 ms 344 KB Output is correct
10 Correct 11 ms 348 KB Output is correct
11 Correct 11 ms 460 KB Output is correct
12 Incorrect 4 ms 344 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 348 KB Output is correct
2 Correct 10 ms 468 KB Output is correct
3 Correct 10 ms 348 KB Output is correct
4 Correct 11 ms 348 KB Output is correct
5 Correct 10 ms 460 KB Output is correct
6 Correct 11 ms 344 KB Output is correct
7 Correct 13 ms 344 KB Output is correct
8 Correct 11 ms 348 KB Output is correct
9 Correct 11 ms 344 KB Output is correct
10 Correct 11 ms 348 KB Output is correct
11 Correct 11 ms 460 KB Output is correct
12 Incorrect 4 ms 344 KB Output isn't correct
13 Halted 0 ms 0 KB -