# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
958595 | 2024-04-06T05:35:42 Z | KasymK | Art Exhibition (JOI18_art) | C++17 | 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
# | Verdict | Execution time | Memory | 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 |
# | Verdict | Execution time | Memory | 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 | - |
# | Verdict | Execution time | Memory | 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 | - |
# | Verdict | Execution time | Memory | 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 | - |