답안 #275274

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
275274 2020-08-20T05:11:10 Z 최은수(#5098) Radio (Balkan15_RADIO) C++17
45 / 100
2000 ms 768 KB
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
ll x[100010],p[100010],s[100010];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,k;
    cin>>n>>k;
    vector<ll>lst;
    for(int i=0;i++<n;)
        cin>>x[i]>>p[i]>>s[i],lst.eb(x[i]-p[i]),lst.eb(x[i]+p[i]);
    sort(all(lst));
    lst.erase(unique(all(lst)),lst.end());
    ll ans=INF;
    ll all=0;
    for(int i=0;i++<n;)
        all+=s[i];
    for(ll&t:lst)
    {
        vector<ll>cost;
        for(int i=0;i++<n;)
            cost.eb(max(abs(t-x[i])-p[i],0ll)+s[i]);
        sort(all(cost));
        ll cc=0;
        for(int i=0;i<k;i++)
            cc+=cost[i];
        ans=min(ans,cc-all);
    }
    cout<<ans<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 360 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 12 ms 384 KB Output is correct
4 Correct 70 ms 384 KB Output is correct
5 Correct 110 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 11 ms 384 KB Output is correct
4 Correct 30 ms 384 KB Output is correct
5 Correct 51 ms 504 KB Output is correct
6 Correct 61 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 12 ms 384 KB Output is correct
4 Correct 70 ms 384 KB Output is correct
5 Correct 110 ms 504 KB Output is correct
6 Execution timed out 2079 ms 768 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 11 ms 384 KB Output is correct
4 Correct 30 ms 384 KB Output is correct
5 Correct 51 ms 504 KB Output is correct
6 Correct 61 ms 504 KB Output is correct
7 Execution timed out 2075 ms 768 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 360 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 12 ms 384 KB Output is correct
11 Correct 70 ms 384 KB Output is correct
12 Correct 110 ms 504 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 11 ms 384 KB Output is correct
16 Correct 30 ms 384 KB Output is correct
17 Correct 51 ms 504 KB Output is correct
18 Correct 61 ms 504 KB Output is correct
19 Execution timed out 2079 ms 768 KB Time limit exceeded
20 Halted 0 ms 0 KB -