제출 #958595

#제출 시각아이디문제언어결과실행 시간메모리
958595KasymKArt Exhibition (JOI18_art)C++17
10 / 100
1064 ms600 KiB
#include "bits/stdc++.h"
using namespace std;

#define int long long

int n;
int ans = -1e18;

vector<int> a, b, vis;

void barla(string s){
    int S = 0;
    int minA = 1e18, maxA = -1e18;
    bool bamy = false;
    for(char &i : s)
        if(i == '1'){
            bamy = true;
            break;
        }
    if(!bamy)
        return;
    for(int i = 0; i < n; ++i)
        if(s[i] == '1'){
            S += b[i];
            minA = min(minA, a[i]);
            maxA = max(maxA, a[i]);
        }
    ans = max(ans, S - (maxA - minA));
}

void f(int x){
    if(x == n){
        // name ucin gecenok
        string s;
        for(int &i : vis)
            s += (i ? '1' : '0');
        barla(s);
        return;
    }
    for(int i = 0; i <= 1; ++i){
        vis[x] = i;
        f(x + 1);
    }
}

void solve(){
    scanf("%lld", &n);
    a.resize(n);
    b.resize(n);
    vis.resize(n);
    for(int i = 0; i < n; ++i)  
        scanf("%lld %lld", &a[i], &b[i]);
    f(0);
    printf("%lld\n", ans);
}

signed main(){
    int t = 1;
    // scanf("%d", &t);
    while(t--)
        solve();
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

art.cpp: In function 'void solve()':
art.cpp:47:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |     scanf("%lld", &n);
      |     ~~~~~^~~~~~~~~~~~
art.cpp:52:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |         scanf("%lld %lld", &a[i], &b[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...