Submission #3441735
Source Code Expand
#include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<algorithm> #include<functional> #include<vector> #include<queue> #include<stack> #include<set> #include<map> using namespace std; #define MOD 1000000007 #define f(i,n) for(int i=0;i<int(n);i++) #define N (1<<18) int a[(2 * N)]; void init(void){ f(i, 2 * N)a[i] = -MOD; return; } void change(int k, int x){ k += N - 1; if (a[k]<x)a[k] = x; else return; while (k > 1){ k = k / 2; a[k] = max(a[2 * k], a[2 * k + 1]); } return; } //探索(0<=l<r<=n)範囲は(l<=x<r)初期は(l,r,1,0,N) int max_search(int l, int r, int k, int sl, int sr){ if (r <= sl || sr <= l)return -MOD; else if (l <= sl&&sr <= r) return a[k]; else{ int vl = max_search(l, r, 2 * k, sl, (sl + sr) / 2); int vr = max_search(l, r, 2 * k + 1, (sl + sr) / 2, sr); return max(vl, vr); } } int main(void){ int b[N]; int s[N]; vector<int>q[N]; int n; int m; int x, y, z; scanf("%d", &n); init(); b[0] = 0; s[0] = b[0]; f(i, n){ scanf("%d", &x); if (x == 0){ b[i + 1] = b[i] + 1; s[i + 1] = b[i + 1]; } else{ b[i + 1] = b[i]; s[i + 1] = b[i + 1]; } } scanf("%d", &m); f(i, m){ scanf("%d %d", &x, &y); q[x].push_back(y); } for (int i = 1; i <= n; i++){ if (b[i - 1]<b[i]){ s[i] = max(s[i - 1] + 1, s[i]); } else s[i] = max(s[i - 1], s[i]); f(j, q[i].size()){ x = s[i - 1] + (q[i][j] - b[q[i][j]]) - (i - 1 - b[i - 1]); y = max_search(i, q[i][j], 1, 0, N); if (y>(-MOD)){ y += (q[i][j] - b[q[i][j]]); z = max(x, y); } else z = x; s[q[i][j]] = max(s[q[i][j]], z); change(q[i][j], z - (q[i][j] - b[q[i][j]])); } f(j, n){ printf("%d ", s[j + 1]); } printf("\n"); } printf("%d\n", n-s[n]); return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - NRE |
User | ptrs |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1863 Byte |
Status | WA |
Exec Time | 2429 ms |
Memory | 145504 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:56:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &n); ^ ./Main.cpp:61:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &x); ^ ./Main.cpp:71:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &m); ^ ./Main.cpp:73:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d %d", &x, &y); ^
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 1000 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example_0, example_1, example_2, example_3, example_4, example_5, example_6 |
All | cent_0, cent_1, cent_2, cent_3, cent_4, cent_5, cent_6, cent_7, cent_8, cent_9, example_0, example_1, example_2, example_3, example_4, example_5, example_6, full_0, full_1, full_10, full_11, full_12, full_13, full_14, full_15, full_16, full_17, full_18, full_19, full_2, full_3, full_4, full_5, full_6, full_7, full_8, full_9, maxrand_0, maxrand_1, maxrand_10, maxrand_11, maxrand_12, maxrand_13, maxrand_14, maxrand_15, maxrand_16, maxrand_17, maxrand_18, maxrand_19, maxrand_2, maxrand_20, maxrand_21, maxrand_22, maxrand_23, maxrand_24, maxrand_25, maxrand_26, maxrand_27, maxrand_28, maxrand_29, maxrand_3, maxrand_4, maxrand_5, maxrand_6, maxrand_7, maxrand_8, maxrand_9, rand_0, rand_1, rand_10, rand_11, rand_12, rand_13, rand_14, rand_15, rand_16, rand_17, rand_18, rand_19, rand_2, rand_3, rand_4, rand_5, rand_6, rand_7, rand_8, rand_9, small_0, small_1, small_2, small_3, small_4, small_5, small_6, small_7, small_8, small_9, smallwidth_0, smallwidth_1, smallwidth_10, smallwidth_11, smallwidth_12, smallwidth_13, smallwidth_14, smallwidth_15, smallwidth_16, smallwidth_17, smallwidth_18, smallwidth_19, smallwidth_2, smallwidth_20, smallwidth_21, smallwidth_22, smallwidth_23, smallwidth_24, smallwidth_25, smallwidth_26, smallwidth_27, smallwidth_28, smallwidth_29, smallwidth_3, smallwidth_4, smallwidth_5, smallwidth_6, smallwidth_7, smallwidth_8, smallwidth_9 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
cent_0 | OLE | 2000 ms | 143736 KB |
cent_1 | OLE | 2027 ms | 144512 KB |
cent_2 | OLE | 2008 ms | 143572 KB |
cent_3 | OLE | 2025 ms | 143996 KB |
cent_4 | OLE | 2010 ms | 144744 KB |
cent_5 | OLE | 2010 ms | 143220 KB |
cent_6 | OLE | 2013 ms | 144120 KB |
cent_7 | OLE | 2001 ms | 143608 KB |
cent_8 | OLE | 1989 ms | 144640 KB |
cent_9 | OLE | 1974 ms | 143348 KB |
example_0 | WA | 4 ms | 8448 KB |
example_1 | WA | 4 ms | 8448 KB |
example_2 | WA | 4 ms | 8448 KB |
example_3 | WA | 4 ms | 8448 KB |
example_4 | WA | 4 ms | 8448 KB |
example_5 | WA | 4 ms | 8448 KB |
example_6 | WA | 4 ms | 8448 KB |
full_0 | OLE | 1963 ms | 141056 KB |
full_1 | OLE | 2008 ms | 144896 KB |
full_10 | OLE | 1964 ms | 141184 KB |
full_11 | OLE | 2017 ms | 144896 KB |
full_12 | OLE | 1970 ms | 141184 KB |
full_13 | OLE | 2025 ms | 145136 KB |
full_14 | OLE | 1919 ms | 141056 KB |
full_15 | OLE | 2012 ms | 145024 KB |
full_16 | OLE | 1952 ms | 141056 KB |
full_17 | OLE | 2010 ms | 144896 KB |
full_18 | OLE | 1964 ms | 141056 KB |
full_19 | OLE | 2092 ms | 145504 KB |
full_2 | OLE | 1948 ms | 141184 KB |
full_3 | OLE | 1998 ms | 145184 KB |
full_4 | OLE | 1970 ms | 141056 KB |
full_5 | OLE | 2012 ms | 144896 KB |
full_6 | OLE | 1968 ms | 141056 KB |
full_7 | OLE | 2201 ms | 144896 KB |
full_8 | OLE | 1982 ms | 141056 KB |
full_9 | OLE | 2004 ms | 145132 KB |
maxrand_0 | OLE | 1959 ms | 141056 KB |
maxrand_1 | OLE | 2012 ms | 144640 KB |
maxrand_10 | OLE | 1953 ms | 141056 KB |
maxrand_11 | OLE | 2011 ms | 144640 KB |
maxrand_12 | OLE | 1952 ms | 141056 KB |
maxrand_13 | OLE | 2019 ms | 144640 KB |
maxrand_14 | OLE | 1949 ms | 141056 KB |
maxrand_15 | OLE | 2014 ms | 144640 KB |
maxrand_16 | OLE | 1979 ms | 141056 KB |
maxrand_17 | OLE | 2007 ms | 144640 KB |
maxrand_18 | OLE | 1969 ms | 141056 KB |
maxrand_19 | OLE | 2013 ms | 144640 KB |
maxrand_2 | OLE | 1957 ms | 141056 KB |
maxrand_20 | OLE | 1971 ms | 141056 KB |
maxrand_21 | OLE | 2018 ms | 144640 KB |
maxrand_22 | OLE | 1978 ms | 141184 KB |
maxrand_23 | OLE | 2017 ms | 144640 KB |
maxrand_24 | OLE | 1971 ms | 141056 KB |
maxrand_25 | OLE | 2014 ms | 144640 KB |
maxrand_26 | OLE | 1964 ms | 141056 KB |
maxrand_27 | OLE | 1987 ms | 144640 KB |
maxrand_28 | OLE | 1975 ms | 141056 KB |
maxrand_29 | OLE | 1991 ms | 144640 KB |
maxrand_3 | OLE | 1977 ms | 144640 KB |
maxrand_4 | OLE | 1963 ms | 141056 KB |
maxrand_5 | OLE | 2020 ms | 144640 KB |
maxrand_6 | OLE | 1973 ms | 141056 KB |
maxrand_7 | OLE | 1991 ms | 144640 KB |
maxrand_8 | OLE | 1962 ms | 141428 KB |
maxrand_9 | OLE | 2429 ms | 144640 KB |
rand_0 | OLE | 2030 ms | 144640 KB |
rand_1 | OLE | 2058 ms | 141568 KB |
rand_10 | OLE | 2018 ms | 144640 KB |
rand_11 | OLE | 1968 ms | 141824 KB |
rand_12 | OLE | 2011 ms | 144640 KB |
rand_13 | OLE | 2005 ms | 143104 KB |
rand_14 | OLE | 1948 ms | 145152 KB |
rand_15 | OLE | 2116 ms | 141056 KB |
rand_16 | OLE | 1991 ms | 144640 KB |
rand_17 | OLE | 2035 ms | 142080 KB |
rand_18 | OLE | 2010 ms | 144640 KB |
rand_19 | OLE | 2010 ms | 144128 KB |
rand_2 | OLE | 2003 ms | 144640 KB |
rand_3 | OLE | 2104 ms | 141824 KB |
rand_4 | OLE | 2008 ms | 144640 KB |
rand_5 | OLE | 2414 ms | 140800 KB |
rand_6 | OLE | 2012 ms | 144640 KB |
rand_7 | OLE | 2021 ms | 141952 KB |
rand_8 | OLE | 1993 ms | 144640 KB |
rand_9 | OLE | 1973 ms | 141312 KB |
small_0 | WA | 4 ms | 8448 KB |
small_1 | WA | 4 ms | 8448 KB |
small_2 | WA | 4 ms | 8448 KB |
small_3 | WA | 4 ms | 8448 KB |
small_4 | WA | 4 ms | 8448 KB |
small_5 | WA | 4 ms | 8448 KB |
small_6 | WA | 4 ms | 8448 KB |
small_7 | WA | 4 ms | 8448 KB |
small_8 | WA | 4 ms | 8448 KB |
small_9 | WA | 4 ms | 8448 KB |
smallwidth_0 | OLE | 1948 ms | 141056 KB |
smallwidth_1 | OLE | 2024 ms | 145024 KB |
smallwidth_10 | OLE | 1949 ms | 141056 KB |
smallwidth_11 | OLE | 2397 ms | 145024 KB |
smallwidth_12 | OLE | 1969 ms | 141056 KB |
smallwidth_13 | OLE | 1999 ms | 145024 KB |
smallwidth_14 | OLE | 1982 ms | 141296 KB |
smallwidth_15 | OLE | 2013 ms | 145024 KB |
smallwidth_16 | OLE | 1976 ms | 141056 KB |
smallwidth_17 | OLE | 2016 ms | 145024 KB |
smallwidth_18 | OLE | 1941 ms | 141056 KB |
smallwidth_19 | OLE | 1974 ms | 145024 KB |
smallwidth_2 | OLE | 1973 ms | 141424 KB |
smallwidth_20 | OLE | 1969 ms | 141056 KB |
smallwidth_21 | OLE | 1949 ms | 145024 KB |
smallwidth_22 | OLE | 1978 ms | 141056 KB |
smallwidth_23 | OLE | 2008 ms | 145024 KB |
smallwidth_24 | OLE | 1952 ms | 141056 KB |
smallwidth_25 | OLE | 1972 ms | 145024 KB |
smallwidth_26 | OLE | 1925 ms | 141056 KB |
smallwidth_27 | OLE | 2010 ms | 145024 KB |
smallwidth_28 | OLE | 1965 ms | 141056 KB |
smallwidth_29 | OLE | 2010 ms | 145024 KB |
smallwidth_3 | OLE | 2007 ms | 145024 KB |
smallwidth_4 | OLE | 1993 ms | 141056 KB |
smallwidth_5 | OLE | 2040 ms | 145024 KB |
smallwidth_6 | OLE | 1976 ms | 141056 KB |
smallwidth_7 | OLE | 1984 ms | 145024 KB |
smallwidth_8 | OLE | 1946 ms | 141056 KB |
smallwidth_9 | OLE | 1997 ms | 145024 KB |