# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
958595 | KasymK | Art Exhibition (JOI18_art) | C++17 | 1064 ms | 600 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |