| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 972297 | vjudge1 | Art Exhibition (JOI18_art) | C++17 | 13 ms | 468 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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();
}
}
컴파일 시 표준 에러 (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... | ||||
