# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
275769 | 2020-08-20T07:41:11 Z | 반딧불(#5115) | Radio (Balkan15_RADIO) | C++17 | 144 ms | 384 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, k; ll x[100002], p[100002], s[100002]; ll ans = LLONG_MAX, tmpAns; vector<ll> v; int main(){ scanf("%d %d", &n, &k); for(int i=0; i<n; i++){ scanf("%lld %lld %lld", &x[i], &p[i], &s[i]); } for(int i=0; i<(1<<n); i++){ if(__builtin_popcount(i) != k) continue; tmpAns = 0; v.clear(); for(int j=0; j<n; j++){ if(i&(1<<j)) v.push_back(x[j]-p[j]), v.push_back(x[j]+p[j]); else tmpAns -= s[j]; } sort(v.begin(), v.end()); for(auto &loc: v){ ll tmp = tmpAns; for(int j=0; j<n; j++){ if(i&(1<<j)) tmp += max(0LL, abs(loc - x[j]) - p[j]); } ans = min(ans, tmp); } } printf("%lld", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 3 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Incorrect | 1 ms | 384 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 144 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 144 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 3 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Incorrect | 1 ms | 384 KB | Output isn't correct |