Submission #3221364
Source Code Expand
/*
cat <<EOF >mistaken-paste
*/
#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <time.h>
#define BIG 2000000007
#define VERYBIG 2000000000000007LL
#define MOD 1000000007
#define FOD 998244353
typedef uint64_t ull;
typedef int64_t sll;
#define N_MAX 1000000
#define M_MAX 200000
#ifdef __cplusplus
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <functional>
#include <array>
using std::queue;
using std::priority_queue;
using std::stack;
using std::tuple;
using std::set;
using std::map;
using std::vector;
using std::greater;
using std::pair;
using std::string;
#endif
typedef struct {
int32_t a;
int32_t b;
} hw;
typedef struct {
sll a;
sll b;
} hwll;
typedef struct {
sll a;
sll b;
sll c;
} hwllc;
typedef struct {
hwll a;
hwll b;
} linell;
ull n, m;
ull h, w;
ull k;
ull q;
sll va, vb, vc, vd, ve, vf;
ull ua, ub, uc, ud, ue, uf;
long double vra, vrb, vrc;
double vda, vdb, vdc;
char ch, dh;
ull umin (ull x, ull y) {
return (x < y) ? x : y;
}
ull umax (ull x, ull y) {
return (x > y) ? x : y;
}
sll smin (sll x, sll y) {
return (x < y) ? x : y;
}
sll smax (sll x, sll y) {
return (x > y) ? x : y;
}
ull gcd (ull x, ull y) {
if (x < y) {
return gcd(y, x);
} else if (y == 0) {
return x;
} else {
return gcd(y, x % y);
}
}
ull bitpow (ull a, ull x, ull modulo) {
ull result = 1;
while (x) {
if (x & 1) {
result *= a;
result %= modulo;
}
x /= 2;
a = (a * a) % modulo;
}
return result;
}
ull divide (ull a, ull b, ull modulo) {
return (a * bitpow(b, modulo - 2, modulo)) % modulo;
}
ull udiff (ull a, ull b) {
if (a >= b) {
return a - b;
} else {
return b - a;
}
}
sll sdiff (sll a, sll b) {
if (a >= b) {
return a - b;
} else {
return b - a;
}
}
int bitcount (ull n) {
int result = 0;
while (n) {
if (n & 1) result++;
n /= 2;
}
return result;
}
// double distance (sll x1, sll y1, sll x2, sll y2) {
// double xdist2, ydist2, origindist, dist;
// xdist2 = (x1 - x2) * (x1 - x2);
// ydist2 = (y1 - y2) * (y1 - y2);
// return sqrt(xdist2 + ydist2);
// }
int32_t pullcomp (const void *left, const void *right) {
ull l = *(ull*)left;
ull r = *(ull*)right;
if (l < r) {
return -1;
}
if (l > r) {
return +1;
}
return 0;
}
int32_t psllcomp (const void *left, const void *right) {
sll l = *(sll*)left;
sll r = *(sll*)right;
if (l < r) {
return -1;
}
if (l > r) {
return +1;
}
return 0;
}
int32_t pcharcomp (const void *left, const void *right) {
char l = *(char*)left;
char r = *(char*)right;
if (l < r) {
return -1;
}
if (l > r) {
return +1;
}
return 0;
}
int32_t pdoublecomp (const void *left, const void *right) {
double l = *(double*)left;
double r = *(double*)right;
if (l < r) {
return -1;
}
if (l > r) {
return +1;
}
return 0;
}
int32_t pstrcomp (const void *left, const void *right) {
char* l = *(char**)left;
char* r = *(char**)right;
return strcmp(l, r);
}
int32_t phwllABcomp (const void *left, const void *right) {
hwll l = *(hwll*)left;
hwll r = *(hwll*)right;
if (l.a < r.a) {
return -1;
}
if (l.a > r.a) {
return +1;
}
if (l.b < r.b) {
return -1;
}
if (l.b > r.b) {
return +1;
}
return 0;
}
int32_t phwllREVcomp (const void *left, const void *right) {
hwll l = *(hwll*)left;
hwll r = *(hwll*)right;
if (l.b < r.b) {
return -1;
}
if (l.b > r.b) {
return +1;
}
if (l.a < r.a) {
return -1;
}
if (l.a > r.a) {
return +1;
}
return 0;
}
int32_t ptriplecomp (const void *left, const void *right) {
hwllc l = *(hwllc*)left;
hwllc r = *(hwllc*)right;
if (l.a < r.a) {
return -1;
}
if (l.a > r.a) {
return +1;
}
if (l.b < r.b) {
return -1;
}
if (l.b > r.b) {
return +1;
}
if (l.c < r.c) {
return -1;
}
if (l.c > r.c) {
return +1;
}
return 0;
}
bool isinrange (sll left, sll x, sll right) {
return (left <= x && x <= right);
}
bool isinrange_soft (sll left, sll x, sll right) {
return (left <= x && x <= right) || (left >= x && x >= right);
}
sll a[N_MAX];
// sll a[3001][3001];
sll b[N_MAX];
// sll b[3001][3001];
sll c[N_MAX];
// sll d[N_MAX];
// sll e[N_MAX];
// char s[N_MAX + 1];
char s[3010][3010];
// char t[N_MAX + 1];
char t[3010][3010];
// hwll xy[N_MAX];
// sll table[1000][1000];
ull dp1[N_MAX];
ull dp2[N_MAX];
void smaller (ull *x, ull y) {
if (*x > y) *x = y;
}
ull solve () {
sll i, j, ki, li;
ull result = 0;
// sll result = 0;
double dresult = 0;
// ull maybe = 0;
sll maybe = 0;
// ull sum = 0;
sll sum = 0;
sll item;
ull *dpcell;
for (i = 0; i <= n; i++) {
dp1[i] = dp2[i] = VERYBIG;
}
dp1[0] = 0;
for (i = 0; i < n; i++) {
ull ok = i, ng = n + 1;
while (ok + 1 < ng) {
ull med = (ok + ng) / 2;
if (2 * (a[med] - a[i + 1]) < k) {
ok = med;
} else {
ng = med;
}
}
smaller(&dp2[i + 1], dp2[i] + 3 * (a[i + 1] - a[i]));
ull x = umin(dp1[i], dp2[i]);
smaller(&dp1[ok], x + k + (a[ok] - a[i]));
smaller(&dp2[ng], x + 3 * (a[ng] - a[i + 1]) + (a[i + 1] - a[i]));
}
result = umin(dp1[n], dp2[n]) + (m - a[n]);
printf("%lld\n", result);
// printf("%.15lf\n", dresult);
// puts(s);
return 0;
success:
// puts("YES");
puts("Yes");
// printf("%llu\n", result);
// puts("0");
// puts("Yay!");
return 0;
fail:
// puts("NO");
// puts("No");
puts("0");
// puts("-1");
// puts("-1 -1 -1");
// puts(":(");
return 1;
}
int32_t main (void) {
int32_t i, j;
int32_t x, y;
// scanf("%llu%llu", &h, &w);
scanf("%llu%llu", &n, &m);
scanf("%llu", &k, &n, &m);
// scanf("%llu%llu", &h, &w);
// scanf("%lld", &va, &vb, &vc, &vd);
// scanf("%llu%llu", &ua, &ub, &uc, &ud);
// scanf("%llu", &q);
// scanf("%s", s);
// scanf("%s", t);
for (i = 0; i < n; i++) {
// scanf("%lld%lld", &xy[i].a, &xy[i].b);
scanf("%lld", &a[i + 1]);
// scanf("%lld", &b[i]);
// scanf("%lld", &c[i]);
// scanf("%lld", &d[i]);
// a[i]--;
// b[i]--;
// c[i]--;
}
// scanf("%llu", &m, &k);
// scanf("%llu", &q);
// for (i = 0; i < n; i++) {
// scanf("%lld", &b[i]);
// b[i]--;
// }
// for (i = 0; i < h; i++) {
// for (j = 0; j < w; j++) {
// scanf("%llu", &table[i][j]);
// }
// }
// for (i = 0; i < h; i++) {
// scanf("%s", &s[i]);
// }
solve();
return 0;
}
Submission Info
Submission Time
2018-09-18 22:03:03+0900
Task
D - Shik and Game
User
sheyasutaka
Language
C (GCC 5.4.1)
Score
1200
Code Size
6837 Byte
Status
AC
Exec Time
19 ms
Memory
11264 KB
Compile Error
./Main.c: In function ‘solve’:
./Main.c:339:9: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘ull {aka long unsigned int}’ [-Wformat=]
printf("%lld\n", result);
^
./Main.c: In function ‘main’:
./Main.c:368:8: warning: format ‘%llu’ expects argument of type ‘long long unsigned int *’, but argument 2 has type ‘ull * {aka long unsigned int *}’ [-Wformat=]
scanf("%llu%llu", &n, &m);
^
./Main.c:368:8: warning: format ‘%llu’ expects argument of type ‘long long unsigned int *’, but argument 3 has type ‘ull * {aka long unsigned int *}’ [-Wformat=]
./Main.c:369:8: warning: format ‘%llu’ expects argument of type ‘long long unsigned int *’, but argument 2 has type ‘ull * {aka long unsigned int *}’ [-Wformat=]
scanf("%llu", &k, &n, &m);
^
./Main.c:369:8: warning: too many arguments for format [-Wformat-extra-args]
./Main.c:378:9: warning: format ‘%lld’ expects argument of type ‘long long int *’, but argument 2 has type ‘sll * {aka long int *}’ [...
Judge Result
Set Name
Sample
Subtask1
All
Score / Max Score
0 / 0
600 / 600
600 / 600
Status
Set Name
Test Cases
Sample
0_00.txt, 0_01.txt, 0_02.txt
Subtask1
0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt
All
0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 2_00.txt, 2_01.txt, 2_02.txt, 2_03.txt, 2_04.txt, 2_05.txt, 2_06.txt, 2_07.txt, 2_08.txt, 2_09.txt, 2_10.txt, 2_11.txt, 2_12.txt, 2_13.txt, 2_14.txt, 2_15.txt, 2_16.txt, 2_17.txt, 2_18.txt, 2_19.txt, 2_20.txt, 2_21.txt, 2_22.txt, 2_23.txt, 2_24.txt, 2_25.txt, 2_26.txt, 2_27.txt, 2_28.txt, 2_29.txt, 2_30.txt, 2_31.txt, 2_32.txt, 2_33.txt, 2_34.txt, 2_35.txt, 2_36.txt, 2_37.txt, 2_38.txt, 2_39.txt, 2_40.txt
Case Name
Status
Exec Time
Memory
0_00.txt
AC
2 ms
8320 KB
0_01.txt
AC
1 ms
8320 KB
0_02.txt
AC
2 ms
8320 KB
1_00.txt
AC
2 ms
8320 KB
1_01.txt
AC
2 ms
8320 KB
1_02.txt
AC
2 ms
8320 KB
1_03.txt
AC
2 ms
8320 KB
1_04.txt
AC
2 ms
8320 KB
1_05.txt
AC
2 ms
8320 KB
1_06.txt
AC
2 ms
8320 KB
1_07.txt
AC
2 ms
8320 KB
1_08.txt
AC
2 ms
8320 KB
1_09.txt
AC
2 ms
8320 KB
1_10.txt
AC
2 ms
8320 KB
1_11.txt
AC
2 ms
8320 KB
1_12.txt
AC
2 ms
8320 KB
1_13.txt
AC
2 ms
8320 KB
1_14.txt
AC
2 ms
8320 KB
1_15.txt
AC
2 ms
8320 KB
1_16.txt
AC
2 ms
8320 KB
1_17.txt
AC
2 ms
8320 KB
1_18.txt
AC
2 ms
8320 KB
1_19.txt
AC
2 ms
8320 KB
2_00.txt
AC
16 ms
11136 KB
2_01.txt
AC
17 ms
11136 KB
2_02.txt
AC
16 ms
11136 KB
2_03.txt
AC
16 ms
11136 KB
2_04.txt
AC
16 ms
11136 KB
2_05.txt
AC
16 ms
11136 KB
2_06.txt
AC
16 ms
11136 KB
2_07.txt
AC
16 ms
11136 KB
2_08.txt
AC
16 ms
11136 KB
2_09.txt
AC
16 ms
11136 KB
2_10.txt
AC
17 ms
11264 KB
2_11.txt
AC
17 ms
11136 KB
2_12.txt
AC
17 ms
11136 KB
2_13.txt
AC
17 ms
11136 KB
2_14.txt
AC
17 ms
11136 KB
2_15.txt
AC
17 ms
11136 KB
2_16.txt
AC
17 ms
11136 KB
2_17.txt
AC
17 ms
11136 KB
2_18.txt
AC
18 ms
11136 KB
2_19.txt
AC
18 ms
11136 KB
2_20.txt
AC
18 ms
11136 KB
2_21.txt
AC
18 ms
11136 KB
2_22.txt
AC
19 ms
11136 KB
2_23.txt
AC
19 ms
11136 KB
2_24.txt
AC
19 ms
11136 KB
2_25.txt
AC
18 ms
11136 KB
2_26.txt
AC
18 ms
11136 KB
2_27.txt
AC
18 ms
11136 KB
2_28.txt
AC
18 ms
11136 KB
2_29.txt
AC
18 ms
11136 KB
2_30.txt
AC
18 ms
11136 KB
2_31.txt
AC
18 ms
11136 KB
2_32.txt
AC
18 ms
11136 KB
2_33.txt
AC
18 ms
11136 KB
2_34.txt
AC
18 ms
11136 KB
2_35.txt
AC
18 ms
11136 KB
2_36.txt
AC
18 ms
11136 KB
2_37.txt
AC
18 ms
11136 KB
2_38.txt
AC
18 ms
11136 KB
2_39.txt
AC
18 ms
11136 KB
2_40.txt
AC
17 ms
11136 KB