响应式网站制作方法,自助建站怎么实现的,网站注册设计,asp.net获取网站地址1113: [Poi2008]海报PLA Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 1025 Solved: 679[Submit][Status][Discuss]Description N个矩形,排成一排. 现在希望用尽量少的矩形海报Cover住它们. Input 第一行给出数字N,代表有N个矩形.N在[1,250000] 下面N行,每行给出矩形的长… 1113: [Poi2008]海报PLA Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 1025 Solved: 679[Submit][Status][Discuss] Description N个矩形,排成一排. 现在希望用尽量少的矩形海报Cover住它们. Input 第一行给出数字N,代表有N个矩形.N在[1,250000] 下面N行,每行给出矩形的长与宽.其值在[1,1000000000]2 1/2 Postering Output 最少数量的海报数. Sample Input 5 1 2 1 3 2 2 2 5 1 4 Sample Output 4 HINT Source [Submit][Status][Discuss] 分析 单调栈 代码 1 /*--- Opinion ---*/2 3 #define HEADER4 #define MYMATH5 // #define FILEIO6 // #define FSTREAM7 // #define FREOPEN8 #define FASTREAD9 #define SHORTNAME10 11 ///// HEADER FILE /////12 13 #ifdef HEADER14 15 #include cmath16 #include string17 #include cstdio18 #include cstring19 #include cstdlib20 #include algorithm21 22 #include sstream23 #include fstream24 #include iostream25 26 #include set27 #include map28 #include list29 #include queue30 #include stack31 #include vector32 #include utility33 #include functional34 35 #endif36 37 ///// SHORTNAME /////38 39 #ifdef SHORTNAME40 41 #define LL long long42 #define ll long long43 #define re register44 #define un unsigned45 #define rb re bool46 #define ri re int47 #define ui un int48 #define rl re LL49 #define ul un LL50 51 #define rep (x, y) for (ri i x; i y; i)52 #define repi(x, y) for (ri i x; i y; i)53 #define repj(x, y) for (ri j x; j y; j)54 #define repk(x, y) for (ri k x; k y; k)55 56 #define upto(x) for (ri i 1; i x; i)57 #define dnto(x) for (ri i x; i 1; --i)58 59 #define up(x) for (ri i 1; i x; i)60 #define dn(x) for (ri i x; i 1; --i)61 62 #define put(x) printf(%lld , (LL)x)63 #define putln(x) printf(%lld\n, (LL)x)64 65 #endif66 67 ///// FASTREAD /////68 69 #ifdef FASTREAD70 71 const int FR_lim 10000000;72 73 char *FR_c;74 75 inline void fsetup(FILE *FR_file)76 {77 FR_c new char[FR_lim];78 fread(FR_c, 1, FR_lim, FR_file);79 }80 81 template class T82 inline void fread(T FR_num)83 {84 FR_num 0; rb FR_neg 0;85 86 while (*FR_c 0)87 if (*FR_c -)88 FR_neg ^ true;89 90 while (*FR_c 0)91 FR_num FR_num*10 *FR_c - 0;92 93 if(FR_neg)FR_num -FR_num;94 }95 96 #endif97 98 ///// FILE I/O /////99
100 #ifdef FILEIO
101
102 FILE *FIN fopen(input.txt, r);
103 FILE *FOUT fopen(output.txt, w);
104
105 #ifndef FSTREAM
106
107 #define fin FIN
108 #define fout FOUT
109
110 #endif
111
112 #endif
113
114 ///// FSTREAM /////
115
116 #ifdef FSTREAM
117
118 std::ifstream fin(input.txt);
119 std::ofstream fout(output.txt);
120
121 #endif
122
123 ///// MYMATH /////
124
125 #ifdef MYMATH
126
127 #define min(a, b) (a b ? a : b)
128 #define max(a, b) (a b ? a : b)
129
130 #define Min(a, b) a min(a, b)
131 #define Max(a, b) a max(a, b)
132
133 #define abs(x) (x 0 ? -x : x)
134
135 #define sqr(x) ((x)*(x))
136
137 #endif
138
139 ///// _MAIN_ /////
140
141 void _main_(void);
142
143 signed main(void)
144 {
145
146 #ifdef FREOPEN
147 freopen(input.txt, r, stdin);
148 freopen(output.txt, w, stdout);
149 #endif
150
151 _main_();
152
153 #ifdef FILEIO
154 fclose(FIN);
155 fclose(FOUT);
156 #endif
157
158 #ifdef FREOPEN
159 fclose(stdin);
160 fclose(stdout);
161 #endif
162
163 #ifdef FSTREAM
164 fin.close();
165 fout.close();
166 #endif
167
168 return 0;
169 }
170
171 /*--- Main ---*/
172
173 #define N 250005
174
175 int n;
176 int ans;
177 int h[N];
178 int stk[N];
179 int tot 0;
180
181 void _main_(void)
182 {
183 fsetup(stdin);
184
185 fread(n);
186
187 ri x;
188
189 up(n)
190 {
191 fread(x); fread(x);
192 while (tot stk[tot] x)--tot;
193 if (tot stk[tot] x)ans;
194 stk[tot] x;
195 }
196
197 putln(n - ans);
198 } BZOJ_1113.cpp 好像那天特别高兴的样子不知不觉就敲了个不明所以的模板 补一份正常的代码。 1 #include bits/stdc.h2 signed main(void) {3 int n, tot 0;4 scanf(%d, n);5 std::stackint stk;6 for (int i 1; i n; i) {7 int h; scanf(%*d%d, h);8 while (!stk.empty() h stk.top())9 stk.pop();
10 if (!stk.empty() h stk.top())
11 tot;
12 stk.push(h);
13 }
14 printf(%d\n, n - tot);
15 } BZOJ_1113.cpp Author: YouSiki转载于:https://www.cnblogs.com/yousiki/p/6091683.html