답안 #104585

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
104585 2019-04-08T09:38:49 Z Hassoony Simfonija (COCI19_simfonija) C++17
44 / 110
53 ms 2192 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod=(1e9+7);
const ll inf=(1ll<<61);
const int MX=1e5+9;
int n,k,a[MX],x;
int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    for(int i=0;i<n;i++)scanf("%d",&x),a[i]-=x;
    sort(a,a+n);
    x=a[(n-1)/2];
    ll ans=0;
    for(int i=0;i<n;i++){
        a[i]-=x;
        a[i]=abs(a[i]);
    }
    sort(a,a+n);
    for(int i=0;i<n-k;i++){
        ans+=a[i];
    }
    cout<<ans<<endl;
}

Compilation message

simfonija.cpp: In function 'int main()':
simfonija.cpp:11:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<n;i++)scanf("%d",&a[i]);
                         ~~~~~^~~~~~~~~~~~
simfonija.cpp:12:39: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<n;i++)scanf("%d",&x),a[i]-=x;
                         ~~~~~~~~~~~~~~^~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 1144 KB Output is correct
2 Correct 42 ms 2168 KB Output is correct
3 Correct 37 ms 2168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 1144 KB Output is correct
2 Correct 38 ms 2192 KB Output is correct
3 Correct 39 ms 2168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 1144 KB Output is correct
2 Correct 43 ms 2168 KB Output is correct
3 Correct 38 ms 2168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 1220 KB Output is correct
2 Correct 35 ms 2168 KB Output is correct
3 Incorrect 34 ms 2140 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 52 ms 1152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 1152 KB Output is correct
2 Incorrect 42 ms 2188 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 53 ms 1208 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 40 ms 1064 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 42 ms 988 KB Output isn't correct
2 Halted 0 ms 0 KB -