답안 #73389

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
73389 2018-08-28T08:12:03 Z 김세빈(#2270) Radio (Balkan15_RADIO) C++11
30 / 100
113 ms 4620 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

vector <ll> L, R;
ll P[101010], K[101010], C[101010];
ll n, k, ans;
ll suml, sumr, cntl, cntr;

int main()
{
	ll i, j, x;
	
	scanf("%lld%lld", &n, &k);
	
	ans = 1e18;
	
	for(i=1; i<=n; i++){
		scanf("%lld%lld%lld", P + i, K + i, C + i);
		L.push_back(P[i] - K[i]);
		R.push_back(P[i] + K[i]);
		suml += P[i] - K[i];
		cntl ++;
	}
	
	sort(L.begin(), L.end());
	sort(R.begin(), R.end());
	
	for(i=0, j=0; i<n || j<n; ){
		if(j == n || (i != n && L[i] <= R[j])){
			cntl --; suml -= L[i];
			x = L[i]; i ++;
		}
		else{
			cntr ++; sumr += R[j];
			x = R[j]; j ++;
		}
		ans = min(ans, suml - cntl * x + cntr * x - sumr);
	}
	
	printf("%lld\n", ans);
	
	return 0;
}

Compilation message

code1.cpp: In function 'int main()':
code1.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld", &n, &k);
  ~~~~~^~~~~~~~~~~~~~~~~~~~
code1.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld%lld", P + i, K + i, C + i);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 356 KB Output is correct
2 Correct 3 ms 432 KB Output is correct
3 Correct 4 ms 432 KB Output is correct
4 Correct 3 ms 464 KB Output is correct
5 Correct 3 ms 464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 464 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 720 KB Output is correct
2 Correct 18 ms 1356 KB Output is correct
3 Correct 33 ms 2628 KB Output is correct
4 Correct 97 ms 3860 KB Output is correct
5 Correct 87 ms 4620 KB Output is correct
6 Correct 113 ms 4620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 4620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4620 KB Output isn't correct
2 Halted 0 ms 0 KB -