Submission #2278009
Source Code Expand
# include <iostream> # include <algorithm> #include <array> # include <cassert> #include <cctype> #include <climits> #include <numeric> # include <vector> # include <string> # include <set> # include <map> # include <cmath> # include <iomanip> # include <functional> # include <tuple> # include <utility> # include <stack> # include <queue> # include <list> # include <bitset> # include <complex> # include <chrono> # include <random> # include <limits.h> # include <unordered_map> # include <unordered_set> # include <deque> # include <cstdio> # include <cstring> using namespace std; using LL = long long; using ULL = unsigned long long; constexpr long long MOD = 1000000000 + 7; constexpr long long INF = std::numeric_limits<long long>::max(); const double PI = acos(-1); #define fir first #define sec second typedef pair<LL, LL> Pll; typedef pair<LL, pair<LL, LL>> Ppll; typedef pair<LL, pair<LL, bitset<100001>>> Pbll; typedef pair<LL, pair<LL, vector<LL>>> Pvll; typedef pair<LL, LL> Vec2; struct Tll { LL first, second, third; }; typedef pair<LL, Tll> Ptll; #define rep(i,rept) for(LL i=0;i<rept;i++) #define Mfor(i,mf) for(LL i=mf-1;i>=0;i--) LL h, w, n, m, k, s, t, q, sum[210000], last, cnt, ans,a[210000]; struct Edge { LL to, cost; }; string str; bool f; vector<Edge>vec[1000]; void YN(bool f) { if (f) cout << "YES" << endl; else cout << "NO" << endl; } void yn(bool f) { if (f) cout << "Yes" << endl; else cout << "No" << endl; } int main() { cin >> n; rep(i, n)cin >> a[i]; a[n] = 0; LL mx = 0; Tll carp = Tll{0,0,0}; do { stack<Pll>st; mx = 0; f = 0; LL ss = 0; rep(i, n+1) { ss += sum[i]; if (sum[i + 1] == 0) { while (!st.empty()) { Pll now = st.top(); if (now.fir <= a[i]) break; st.pop(); if (mx < (i - now.sec)*(now.fir-ss)) { mx = (i - now.sec)*(now.fir-ss); carp = Tll{ now.sec, i, now.fir }; } } if (st.empty()&&mx!=0) { f = 1; ans++; sum[carp.fir] += carp.third; sum[carp.sec + 1] -= carp.third; mx = 0; } if ((st.empty()?1:st.top().fir < a[i]&&a[i]>0)) st.push(Pll(a[i], i)); } else { while (!st.empty()) { Pll now = st.top(); st.pop(); if (mx < (i - now.sec)*(now.fir-ss)) { mx = (i - now.sec)*(now.fir-ss); carp = Tll{ now.sec, i, now.fir }; } } if (mx != 0) { f = 1; ans++; sum[carp.fir] += carp.third-ss; sum[carp.sec + 1] -= carp.third-ss; mx = 0; } } } } while (f == 1); cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - カーペット |
User | akusyounin |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 2663 Byte |
Status | WA |
Exec Time | 2103 ms |
Memory | 5120 KB |
Judge Result
Set Name | All | ||||||
---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 250 | ||||||
Status |
|
Set Name | Test Cases |
---|---|
All | 00_max_04.txt, 00_max_05.txt, 00_max_06.txt, 00_max_07.txt, 00_max_08.txt, 00_max_09.txt, 00_max_10.txt, 00_min_00.txt, 00_min_01.txt, 00_min_02.txt, 00_min_03.txt, 00_rand_18.txt, 00_rand_19.txt, 00_rand_20.txt, 00_rand_21.txt, 00_rand_22.txt, 00_rand_23.txt, 00_rand_30.txt, 00_rand_31.txt, 00_rand_32.txt, 00_rand_33.txt, 00_rand_34.txt, 00_rand_35.txt, 00_rand_36.txt, 00_rand_37.txt, 00_sample_00.txt, 00_sample_01.txt, 10_max_11.txt, 10_max_12.txt, 10_max_13.txt, 10_max_14.txt, 10_max_15.txt, 10_max_16.txt, 10_max_17.txt, 10_rand_24.txt, 10_rand_25.txt, 10_rand_26.txt, 10_rand_27.txt, 10_rand_28.txt, 10_rand_29.txt, 10_rand_38.txt, 10_rand_39.txt, 10_rand_40.txt, 10_rand_41.txt, 10_rand_42.txt, 10_rand_43.txt, 10_rand_44.txt, 10_rand_45.txt, 10_random_00.txt, 10_random_01.txt, 10_random_02.txt, 10_random_03.txt, 10_random_04.txt, 10_random_05.txt, 10_random_06.txt, 10_random_07.txt, 10_random_08.txt, 10_random_09.txt, 10_random_10.txt, 10_random_11.txt, 10_random_12.txt, 10_random_13.txt, 10_random_14.txt, 10_random_15.txt, 10_random_16.txt, 10_random_17.txt, 10_random_18.txt, 10_random_19.txt, 10_random_20.txt, 10_random_21.txt, 10_random_22.txt, 10_random_23.txt, 10_random_24.txt, 10_random_25.txt, 10_random_26.txt, 10_random_27.txt, 10_random_28.txt, 10_random_29.txt, 10_random_30.txt, 10_random_31.txt, 10_random_32.txt, 10_random_33.txt, 10_random_34.txt, 10_random_35.txt, 10_random_36.txt, 10_random_37.txt, 10_random_38.txt, 10_random_39.txt, 10_random_40.txt, 10_random_41.txt, 10_random_42.txt, 10_random_43.txt, 10_random_44.txt, 10_random_45.txt, 10_random_46.txt, 10_random_47.txt, 10_random_48.txt, 10_random_49.txt, 10_random_50.txt, 10_random_51.txt, 10_random_52.txt, 10_random_53.txt, 10_random_54.txt, 10_random_55.txt, 10_random_56.txt, 10_random_57.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_max_04.txt | WA | 2 ms | 256 KB |
00_max_05.txt | WA | 1 ms | 256 KB |
00_max_06.txt | AC | 2 ms | 256 KB |
00_max_07.txt | WA | 1 ms | 256 KB |
00_max_08.txt | AC | 1 ms | 256 KB |
00_max_09.txt | AC | 2 ms | 256 KB |
00_max_10.txt | WA | 1 ms | 256 KB |
00_min_00.txt | AC | 1 ms | 256 KB |
00_min_01.txt | AC | 1 ms | 256 KB |
00_min_02.txt | AC | 1 ms | 256 KB |
00_min_03.txt | WA | 1 ms | 256 KB |
00_rand_18.txt | WA | 1 ms | 256 KB |
00_rand_19.txt | WA | 1 ms | 256 KB |
00_rand_20.txt | WA | 1 ms | 256 KB |
00_rand_21.txt | WA | 2 ms | 256 KB |
00_rand_22.txt | WA | 2 ms | 256 KB |
00_rand_23.txt | WA | 2 ms | 256 KB |
00_rand_30.txt | WA | 1 ms | 256 KB |
00_rand_31.txt | WA | 1 ms | 256 KB |
00_rand_32.txt | WA | 1 ms | 256 KB |
00_rand_33.txt | WA | 1 ms | 256 KB |
00_rand_34.txt | WA | 2 ms | 256 KB |
00_rand_35.txt | WA | 2 ms | 256 KB |
00_rand_36.txt | WA | 2 ms | 256 KB |
00_rand_37.txt | WA | 2 ms | 256 KB |
00_sample_00.txt | AC | 1 ms | 256 KB |
00_sample_01.txt | AC | 1 ms | 256 KB |
10_max_11.txt | WA | 86 ms | 1792 KB |
10_max_12.txt | WA | 64 ms | 1792 KB |
10_max_13.txt | AC | 82 ms | 3456 KB |
10_max_14.txt | WA | 92 ms | 5120 KB |
10_max_15.txt | AC | 33 ms | 1792 KB |
10_max_16.txt | AC | 85 ms | 1792 KB |
10_max_17.txt | WA | 76 ms | 3456 KB |
10_rand_24.txt | TLE | 2103 ms | 2432 KB |
10_rand_25.txt | TLE | 2103 ms | 2432 KB |
10_rand_26.txt | TLE | 2103 ms | 2560 KB |
10_rand_27.txt | TLE | 2103 ms | 3328 KB |
10_rand_28.txt | TLE | 2103 ms | 3328 KB |
10_rand_29.txt | TLE | 2103 ms | 3328 KB |
10_rand_38.txt | WA | 6 ms | 384 KB |
10_rand_39.txt | WA | 34 ms | 896 KB |
10_rand_40.txt | WA | 34 ms | 896 KB |
10_rand_41.txt | WA | 89 ms | 1792 KB |
10_rand_42.txt | WA | 90 ms | 1792 KB |
10_rand_43.txt | WA | 90 ms | 1792 KB |
10_rand_44.txt | TLE | 2103 ms | 3328 KB |
10_rand_45.txt | WA | 92 ms | 1792 KB |
10_random_00.txt | AC | 1 ms | 256 KB |
10_random_01.txt | AC | 1 ms | 256 KB |
10_random_02.txt | AC | 1 ms | 256 KB |
10_random_03.txt | WA | 1 ms | 256 KB |
10_random_04.txt | WA | 2 ms | 256 KB |
10_random_05.txt | WA | 2 ms | 256 KB |
10_random_06.txt | AC | 2 ms | 256 KB |
10_random_07.txt | WA | 1 ms | 256 KB |
10_random_08.txt | AC | 1 ms | 256 KB |
10_random_09.txt | AC | 2 ms | 256 KB |
10_random_10.txt | WA | 1 ms | 256 KB |
10_random_11.txt | WA | 86 ms | 1792 KB |
10_random_12.txt | WA | 64 ms | 1792 KB |
10_random_13.txt | AC | 82 ms | 3456 KB |
10_random_14.txt | WA | 91 ms | 5120 KB |
10_random_15.txt | AC | 33 ms | 1792 KB |
10_random_16.txt | AC | 81 ms | 1792 KB |
10_random_17.txt | WA | 76 ms | 3456 KB |
10_random_18.txt | WA | 1 ms | 256 KB |
10_random_19.txt | WA | 1 ms | 256 KB |
10_random_20.txt | WA | 2 ms | 256 KB |
10_random_21.txt | WA | 2 ms | 256 KB |
10_random_22.txt | WA | 2 ms | 256 KB |
10_random_23.txt | WA | 2 ms | 256 KB |
10_random_24.txt | TLE | 2103 ms | 2560 KB |
10_random_25.txt | TLE | 2103 ms | 2432 KB |
10_random_26.txt | TLE | 2103 ms | 2560 KB |
10_random_27.txt | TLE | 2103 ms | 3456 KB |
10_random_28.txt | TLE | 2103 ms | 3456 KB |
10_random_29.txt | TLE | 2103 ms | 3456 KB |
10_random_30.txt | WA | 2 ms | 256 KB |
10_random_31.txt | WA | 1 ms | 256 KB |
10_random_32.txt | WA | 1 ms | 256 KB |
10_random_33.txt | WA | 2 ms | 256 KB |
10_random_34.txt | WA | 2 ms | 256 KB |
10_random_35.txt | WA | 2 ms | 256 KB |
10_random_36.txt | WA | 14 ms | 512 KB |
10_random_37.txt | TLE | 2103 ms | 2048 KB |
10_random_38.txt | WA | 18 ms | 640 KB |
10_random_39.txt | WA | 14 ms | 512 KB |
10_random_40.txt | TLE | 2103 ms | 2176 KB |
10_random_41.txt | WA | 87 ms | 1792 KB |
10_random_42.txt | WA | 87 ms | 1792 KB |
10_random_43.txt | WA | 87 ms | 1792 KB |
10_random_44.txt | WA | 90 ms | 1792 KB |
10_random_45.txt | WA | 87 ms | 1792 KB |
10_random_46.txt | WA | 87 ms | 1792 KB |
10_random_47.txt | TLE | 2103 ms | 1920 KB |
10_random_48.txt | WA | 90 ms | 2048 KB |
10_random_49.txt | WA | 84 ms | 2176 KB |
10_random_50.txt | WA | 183 ms | 3072 KB |
10_random_51.txt | WA | 182 ms | 3072 KB |
10_random_52.txt | WA | 99 ms | 3460 KB |
10_random_53.txt | TLE | 2103 ms | 3856 KB |
10_random_54.txt | WA | 109 ms | 3348 KB |
10_random_55.txt | WA | 99 ms | 3468 KB |
10_random_56.txt | WA | 97 ms | 2596 KB |
10_random_57.txt | TLE | 2103 ms | 3500 KB |