이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define all(a) a.begin(), a.end()
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;
const int N = 100 + 5;
const int mod = 1e9 + 7;
void print(){cerr << '\n';} template<typename T1, typename ...T2>
void print(const T1 &a, const T2 &...b){cerr << a << ' ', print(b...);}
int n, m;
int a[N];
ll calc(int x)
{
ll res = 0;
for(int i = 1; i <= m; i++)
res += abs(x - a[i]);
}
void sub1()
{
for(int i = 1; i <= m; i++)
{
int t;
cin >> t >> a[i];
}
ll res = 1e17;
for(int i = 1; i <= m; i++)
res = min(res, calc(a[i]));
cout << res;
}
void solve()
{
cin >> n >> m;
if(n == 1) sub1();
}
signed main()
{
// freopen("fireworks.inp", "r", stdin);
// freopen("fireworks.out", "w", stdout);
cin.tie(0) -> sync_with_stdio(0);
int t = 1;
// cin >> t;
while(t--) solve();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
fireworks.cpp: In function 'll calc(int)':
fireworks.cpp:25:1: warning: no return statement in function returning non-void [-Wreturn-type]
25 | }
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |