답안 #275623

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
275623 2020-08-20T06:47:20 Z 반딧불(#5115) Radio (Balkan15_RADIO) C++17
0 / 100
102 ms 504 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, loc, tmpAns;
vector<ll> v;

int main(){
    scanf("%d %d", &n, &k);
    for(int i=0; i<n; i++){
        scanf("%d %d %d", &x[i], &p[i], &s[i]);
        v.push_back(x[i]-p[i]);
        v.push_back(x[i]+p[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());
        loc = v[(int)v.size()/2-1];
        for(int j=0; j<n; j++) if(i&(1<<j)) tmpAns += max(0LL, abs(loc - x[j]) - p[j]);
        ans = min(ans, tmpAns);
    }
    printf("%lld", ans);
}

Compilation message

radio.cpp: In function 'int main()':
radio.cpp:15:17: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'll*' {aka 'long long int*'} [-Wformat=]
   15 |         scanf("%d %d %d", &x[i], &p[i], &s[i]);
      |                ~^         ~~~~~
      |                 |         |
      |                 int*      ll* {aka long long int*}
      |                %lld
radio.cpp:15:20: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'll*' {aka 'long long int*'} [-Wformat=]
   15 |         scanf("%d %d %d", &x[i], &p[i], &s[i]);
      |                   ~^             ~~~~~
      |                    |             |
      |                    int*          ll* {aka long long int*}
      |                   %lld
radio.cpp:15:23: warning: format '%d' expects argument of type 'int*', but argument 4 has type 'll*' {aka 'long long int*'} [-Wformat=]
   15 |         scanf("%d %d %d", &x[i], &p[i], &s[i]);
      |                      ~^                 ~~~~~
      |                       |                 |
      |                       int*              ll* {aka long long int*}
      |                      %lld
radio.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
radio.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   15 |         scanf("%d %d %d", &x[i], &p[i], &s[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 9 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
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 102 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 102 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 9 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