Submission #104583

# Submission time Handle Problem Language Result Execution time Memory
104583 2019-04-08T09:33:59 Z Hassoony Simfonija (COCI19_simfonija) C++17
0 / 110
1000 ms 4400 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],b[MX],c[MX];
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",&b[i]);
    for(int i=0;i<n;i++)c[i]=a[i]-b[i];
    sort(c,c+n);
    int x=c[(n-1)/2];
    ll ans=0;
    set<int>s;
    for(int i=0;i<n;i++){
        c[i]-=x;
        s.insert(abs(c[i]));
//        cout<<c[i]<<" ";
    }
    while(k+1<n){
        k++;
        ans+=*s.begin();
        s.erase(s.begin());
    }
    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: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",&b[i]);
                         ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 1064 ms 384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1050 ms 2936 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1043 ms 2936 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1057 ms 2808 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1031 ms 1912 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1014 ms 4400 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1025 ms 2300 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1053 ms 4344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1046 ms 2552 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1049 ms 2576 KB Time limit exceeded
2 Halted 0 ms 0 KB -