Submission #846814

# Submission time Handle Problem Language Result Execution time Memory
846814 2023-09-08T13:34:18 Z KK_1729 Road Construction (JOI21_road_construction) C++14
5 / 100
2246 ms 2097152 KB
#include <bits/stdc++.h>
using namespace std;

// -------Macros---------
#define int long long
#define double long long double
#define pb push_back
#define str string
#define vi vector<int>
#define mp make_pair
#define mi map<int, int>
#define umi unordered_map<int, int>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define all(a) a.begin(), a.end()
#define endl "\n"
// ------------------------

// --------------------------Constants------------------------------
const int INF = 1e17;
const int MOD = 1e9+7;
const int MOD2 = 998244353;
// const long long double PI = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679;
// -------------------------------------------------------------------

// ----------------------Pre Written Functions---------------------------

int sum(vector<int> a){ // Returns the sum of values in a vector<int>
    int total = 0;
    for (int x : a) total += x;
    return total;
}

template<typename T>
void printVector(T a){
    // cout << "[ ";
    for (auto x: a) cout << x << " ";
    cout << endl;
}

template<typename T>
void printMap(T a){
    cout << "{ ";
    for (auto x: a){
        cout << x.first << ": " << x.second << " ";
    }
    cout << "}" << endl;
}

int gcd(int a, int b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
 
// Function to return LCM of two numbers
int lcm(int a, int b)
{
    return (a / gcd(a, b)) * b;
}
// ------------------------------------------------------------------------



vi decToBinary(int n)
{
    // array to store binary number
    vi binaryNum(100);
 
    // counter for binary array
    int i = 0;
    while (n > 0) {
 
        // storing remainder in binary array
        binaryNum[i] = n % 2;
        n = n / 2;
        i++;
    }
 
    return binaryNum;
}
int ceildiv(int x, int y){
    return (x+y-1)/y;
}
int min_element(vi a){
    int m = 10000000000000;
    for (auto x: a){
        m = min(m, x);
    }
    return m;
}
int max_element(vi a){
    int m = -1;
    for (auto x: a){
        m = max(m, x);
    }
    return m;
}
void solve(){
    int n, k; cin >> n >> k;
    vector<pair<int, int>> points;
    FOR(i,0,n){
        int x, y; cin >> x >> y;
        points.pb({x, y});
    }
    vector<int> distances;
    FOR(i,0,n){
        FOR(j,i+1,n){
            distances.pb(abs(points[i].first-points[j].first)+abs(points[i].second-points[j].second));
        }
    }
    sort(all(distances));
    FOR(i,0,k){
        cout << distances[i] << endl;
    }
}
int32_t main(){
    // FastIO
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // int t; cin >> t;
    int t = 1;
    for (int tc = 1; tc <= t; ++tc){
        // cout << "Case #" << tc << ": ";
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 53 ms 7100 KB Output is correct
2 Correct 59 ms 7108 KB Output is correct
3 Correct 36 ms 5132 KB Output is correct
4 Correct 35 ms 5068 KB Output is correct
5 Correct 51 ms 6356 KB Output is correct
6 Correct 20 ms 5712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 2246 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1022 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1022 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 53 ms 7100 KB Output is correct
2 Correct 59 ms 7108 KB Output is correct
3 Correct 36 ms 5132 KB Output is correct
4 Correct 35 ms 5068 KB Output is correct
5 Correct 51 ms 6356 KB Output is correct
6 Correct 20 ms 5712 KB Output is correct
7 Runtime error 981 ms 2097152 KB Execution killed with signal 9
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 53 ms 7100 KB Output is correct
2 Correct 59 ms 7108 KB Output is correct
3 Correct 36 ms 5132 KB Output is correct
4 Correct 35 ms 5068 KB Output is correct
5 Correct 51 ms 6356 KB Output is correct
6 Correct 20 ms 5712 KB Output is correct
7 Runtime error 2246 ms 2097152 KB Execution killed with signal 9
8 Halted 0 ms 0 KB -