Submission #970532

# Submission time Handle Problem Language Result Execution time Memory
970532 2024-04-26T16:39:30 Z hariaakas646 Stone Arranging 2 (JOI23_ho_t1) C++14
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>

using namespace std;

#define scd(t) scanf("%d", &t)
#define sclld(t) scanf("%lld", &t)
#define forr(i, j, k) for (int i = j; i < k; i++)
#define frange(i, j) forr(i, 0, j)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<lli> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long double ld;


void usaco()
{
    freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin);
//    freopen("problem.out", "w", stdout);
}

int main() {
    // usaco();
    int n;
    lli t;
    scd(n);
    sclld(t);

    vll vec(n);

    frange(i, n) {
        sclld(vec[i]);
        vec[i] %= t;
    }

    sort(all(vec));

    lli v = vec[n/2];

    lli tot = (vec.back() - vec.front() + 1)/2;
    frange(i, n-1) {
        lli v1 = vec[i] + t;
        lli v2 = vec[i+1];
        tot = min(tot, (v1 - v2 + 1)/2);
    }

    printf("%lld", tot);
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:50:9: warning: unused variable 'v' [-Wunused-variable]
   50 |     lli v = vec[n/2];
      |         ^
Main.cpp: In function 'void usaco()':
Main.cpp:30:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |     freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
Main.cpp:38:5: note: in expansion of macro 'scd'
   38 |     scd(n);
      |     ^~~
Main.cpp:6:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 | #define sclld(t) scanf("%lld", &t)
      |                  ~~~~~^~~~~~~~~~~~
Main.cpp:39:5: note: in expansion of macro 'sclld'
   39 |     sclld(t);
      |     ^~~~~
Main.cpp:6:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 | #define sclld(t) scanf("%lld", &t)
      |                  ~~~~~^~~~~~~~~~~~
Main.cpp:44:9: note: in expansion of macro 'sclld'
   44 |         sclld(vec[i]);
      |         ^~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -