Submission #523779

# Submission time Handle Problem Language Result Execution time Memory
523779 2022-02-08T07:23:07 Z vonatlus Fireworks (APIO16_fireworks) C++17
0 / 100
5 ms 204 KB
/// adil sultanov | vonat1us 

#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:36777216")

#include<bits/stdc++.h>

#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
#define all(z) (z).begin(), (z).end()
 
using namespace std;

using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7; 
const int INF = 1e9 + 1e2;
  
void fin() {
#ifdef AM
    freopen(".in", "r", stdin);
#endif        
}                   

const bool flag = 0;

const int N = 3e5+10;

ll p[N], c[N];

void ma1n() {
    int n, m;
    cin >> n >> m;
    if (n == 1) {
        ll sum = 0;
        for (int i = 0; i < m; ++i) {
            cin >> p[i] >> c[i];
            sum += c[i];
        }
        ll x = sum/m, ans = (1ll<<50);
        for (ll i = max(0ll, x-500000); i <= x+500000; ++i) {
            ll res = 0;
            for (int j = 0; j < m; ++j) {
                res += abs(x-c[j]);
            }
            ans = min(ans, res);
        }
        cout << ans, exit(0);  
    }
} 

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), fin();
    int ts = 1;
    if (flag) {
        cin >> ts;
    }
    while (ts--) {
        ma1n(); 
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 204 KB Output is correct
2 Incorrect 5 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 204 KB Output is correct
2 Incorrect 5 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 204 KB Output is correct
2 Incorrect 5 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -