結果
問題 | No.704 ゴミ拾い Medium |
ユーザー | azbrugby |
提出日時 | 2019-03-16 18:47:54 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,695 bytes |
コンパイル時間 | 683 ms |
コンパイル使用メモリ | 80,516 KB |
実行使用メモリ | 17,848 KB |
最終ジャッジ日時 | 2024-07-01 22:37:45 |
合計ジャッジ時間 | 5,895 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
8,320 KB |
testcase_01 | AC | 4 ms
8,320 KB |
testcase_02 | AC | 4 ms
8,192 KB |
testcase_03 | AC | 4 ms
8,448 KB |
testcase_04 | WA | - |
testcase_05 | AC | 5 ms
8,192 KB |
testcase_06 | AC | 5 ms
8,320 KB |
testcase_07 | AC | 5 ms
8,320 KB |
testcase_08 | AC | 4 ms
8,320 KB |
testcase_09 | AC | 4 ms
8,192 KB |
testcase_10 | AC | 4 ms
8,320 KB |
testcase_11 | AC | 4 ms
8,320 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | AC | 5 ms
8,064 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | AC | 143 ms
17,504 KB |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | AC | 118 ms
17,664 KB |
testcase_35 | AC | 120 ms
17,536 KB |
testcase_36 | AC | 118 ms
17,416 KB |
testcase_37 | AC | 119 ms
17,380 KB |
testcase_38 | AC | 117 ms
17,424 KB |
testcase_39 | AC | 118 ms
17,536 KB |
testcase_40 | AC | 118 ms
17,648 KB |
testcase_41 | AC | 119 ms
17,540 KB |
testcase_42 | AC | 118 ms
17,536 KB |
testcase_43 | AC | 119 ms
17,536 KB |
testcase_44 | AC | 4 ms
8,320 KB |
testcase_45 | AC | 5 ms
8,192 KB |
testcase_46 | AC | 128 ms
17,480 KB |
testcase_47 | AC | 129 ms
17,664 KB |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:63:45: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘ll*’ {aka ‘long long int*’} [-Wformat=] 63 | for (int i = 1; i <= n; i++)scanf("%d", a + i); | ~^ ~~~~~ | | | | int* ll* {aka long long int*} | %lld main.cpp:64:45: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘ll*’ {aka ‘long long int*’} [-Wformat=] 64 | for (int i = 1; i <= n; i++)scanf("%d", x + i); | ~^ ~~~~~ | | | | int* ll* {aka long long int*} | %lld main.cpp:65:45: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘ll*’ {aka ‘long long int*’} [-Wformat=] 65 | for (int i = 1; i <= n; i++)scanf("%d", y + i); | ~^ ~~~~~ | | | | int* ll* {aka long long int*} | %lld main.cpp:63:42: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 63 | for (int i = 1; i <= n; i++)scanf("%d", a + i); | ~~~~~^~~~~~~~~~~~~ main.cpp:64:42: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 64 | for (int i = 1; i <= n; i++)scanf("%d", x + i); |
ソースコード
#include <iostream> #include <algorithm> #include <cstring> #include <sstream> #include <map> #include <queue> #include <set> #include <vector> #include <stack> #include <cstdio> #include <cmath> #include <bitset> #define mk make_pair #define pb push_back using namespace std; typedef long long int ll; typedef pair<ll, ll> pos; const ll MOD = 1234567, N = 300010, dx[4] = { -1,1,0,0 }, dy[4] = { 0,0,-1,1 }, MIN = -72340172838, MAX = 72340172838; const int S = 60; ll mn(ll a, ll b) { if (a == -1)return b; if (b == -1)return a; return min(a, b); } static ll gcd(ll v1, ll v2) { if (v1 == 0)return v2; if (v2 == 0)return v1; if (v2 > v1)return gcd(v2%v1, v1); return gcd(v1%v2, v2); } ll pw(ll v1, ll v2) { ll v3 = 1; while (v2 > 0) { if (v2 % 2)v3 = (v3*v1) % MOD; v1 = (v1*v1) % MOD; v2 /= 2; } return v3; } ll n, a[N], dp[N],bt1[N],bt2[N],x[N],y[N]; void ad(ll v1, ll v2,ll bt[]) { while (v1 < N) { bt[v1] = mn(bt[v1],v2); v1 += v1 & -v1; } } int sm(ll v1,ll bt[]) { ll v2 = -1; while (v1 > 0) { v2 =mn(bt[v1],bt[v1]); v1 -= v1 & -v1; } return v2; } int main() { cin >> n; memset(bt1, -1, sizeof(bt1)); memset(bt2, -1, sizeof(bt2)); for (int i = 1; i <= n; i++)scanf("%d", a + i); for (int i = 1; i <= n; i++)scanf("%d", x + i); for (int i = 1; i <= n; i++)scanf("%d", y + i); for (int i = 1; i <= n; i++) { ll xi = upper_bound(x + 1, x + n + 1, a[i]) - x - 1; ad(i, dp[i - 1] - x[i] + y[i], bt1); ad(n + 1 - i, dp[i - 1] + x[i] + y[i], bt2); dp[i] = -1; ll v1 = sm(xi, bt1), v2 = sm(n + 1 - (xi + 1), bt2); if(v1!=-1) dp[i] = mn(dp[i],a[i] + v1); if(v2!=-1) dp[i] = mn(dp[i], v2 - a[i]); } cout << dp[n] << endl; return 0; }