제출 #276609

#제출 시각아이디문제언어결과실행 시간메모리
276609arnold518Radio (Balkan15_RADIO)C++14
0 / 100
1 ms256 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1000;

struct Data
{
	int X, P, S;
};

int N, K;
Data A[MAXN+10];

int main()
{
	scanf("%d%d", &N, &K);
	for(int i=1; i<=N; i++) scanf("%d%d%d", &A[i].X, &A[i].P, &A[i].S);
	if(N==1) return !printf("0\n");

	ll ans=1e18;
	for(int i=1; i<N; i++)
	{
		vector<ll> V; int cnt=0;
		for(int j=1; j<=i; j++) V.push_back(A[j].X+A[j].P);
		for(int j=i+1; j<=N; j++) V.push_back(A[j].X-A[j].P), cnt++;
		sort(V.begin(), V.end());
		ll k=V[cnt-1];
		ll now=0;
		for(int j=1; j<=i; j++) now+=max(0ll, k-A[j].X-A[j].P);
		for(int j=i+1; j<=N; j++) now+=max(0ll, A[j].X-A[j].P-k);
		ans=min(ans, now);
	}
	printf("%lld\n", ans);
}

컴파일 시 표준 에러 (stderr) 메시지

radio.cpp: In function 'int main()':
radio.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |  scanf("%d%d", &N, &K);
      |  ~~~~~^~~~~~~~~~~~~~~~
radio.cpp:21:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   21 |  for(int i=1; i<=N; i++) scanf("%d%d%d", &A[i].X, &A[i].P, &A[i].S);
      |                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...