답안 #958595

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
958595 2024-04-06T05:35:42 Z KasymK Art Exhibition (JOI18_art) C++17
10 / 100
1000 ms 600 KB
#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;
}

Compilation message

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]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 428 KB Output is correct
2 Correct 10 ms 432 KB Output is correct
3 Correct 10 ms 432 KB Output is correct
4 Correct 10 ms 348 KB Output is correct
5 Correct 10 ms 600 KB Output is correct
6 Correct 10 ms 440 KB Output is correct
7 Correct 10 ms 344 KB Output is correct
8 Correct 10 ms 344 KB Output is correct
9 Correct 10 ms 348 KB Output is correct
10 Correct 10 ms 348 KB Output is correct
11 Correct 10 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 428 KB Output is correct
2 Correct 10 ms 432 KB Output is correct
3 Correct 10 ms 432 KB Output is correct
4 Correct 10 ms 348 KB Output is correct
5 Correct 10 ms 600 KB Output is correct
6 Correct 10 ms 440 KB Output is correct
7 Correct 10 ms 344 KB Output is correct
8 Correct 10 ms 344 KB Output is correct
9 Correct 10 ms 348 KB Output is correct
10 Correct 10 ms 348 KB Output is correct
11 Correct 10 ms 348 KB Output is correct
12 Execution timed out 1064 ms 348 KB Time limit exceeded
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 428 KB Output is correct
2 Correct 10 ms 432 KB Output is correct
3 Correct 10 ms 432 KB Output is correct
4 Correct 10 ms 348 KB Output is correct
5 Correct 10 ms 600 KB Output is correct
6 Correct 10 ms 440 KB Output is correct
7 Correct 10 ms 344 KB Output is correct
8 Correct 10 ms 344 KB Output is correct
9 Correct 10 ms 348 KB Output is correct
10 Correct 10 ms 348 KB Output is correct
11 Correct 10 ms 348 KB Output is correct
12 Execution timed out 1064 ms 348 KB Time limit exceeded
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 428 KB Output is correct
2 Correct 10 ms 432 KB Output is correct
3 Correct 10 ms 432 KB Output is correct
4 Correct 10 ms 348 KB Output is correct
5 Correct 10 ms 600 KB Output is correct
6 Correct 10 ms 440 KB Output is correct
7 Correct 10 ms 344 KB Output is correct
8 Correct 10 ms 344 KB Output is correct
9 Correct 10 ms 348 KB Output is correct
10 Correct 10 ms 348 KB Output is correct
11 Correct 10 ms 348 KB Output is correct
12 Execution timed out 1064 ms 348 KB Time limit exceeded
13 Halted 0 ms 0 KB -