답안 #690036

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
690036 2023-01-30T03:34:09 Z vjudge1 Fireworks (APIO16_fireworks) C++14
0 / 100
1 ms 212 KB
#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;
}

Compilation message

fireworks.cpp: In function 'll calc(int)':
fireworks.cpp:25:1: warning: no return statement in function returning non-void [-Wreturn-type]
   25 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -