821C - Okabe and Boxes 思路:模拟.因为只需要比较栈顶和当前要删除的值就可以了,所以如果栈顶和当前要删除的值不同时,栈就可以清空了(因为下一次的栈顶不可能出现在前面那些值中). 代码: #include<bits/stdc++.h> using namespace std; #define ll long long vector<int>st; int main() { ios::sync_with_stdio(false); cin.tie(); ,ans=…
C. Okabe and Boxes time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Okabe and Super Hacker Daru are stacking and removing boxes. There are n boxes numbered from 1 to n. Initially there are…
题目链接:http://codeforces.com/problemset/problem/551/C time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Professor GukiZ is concerned about making his way to school, because massive piles of bo…
Problem C. GukiZ hates Boxes Solution: 假设最后一个非零的位置为K,所有位置上的和为S 那么答案的范围在[K+1,K+S]. 二分这个答案ans,然后对每个人尽量在ans时间内搬最多的砖.可以得出至少需要多少个人才能搬完.这个可以在O(n)的时间内利用贪心得到 只要判断需要的人数是否小于等于实际的人数就好了 时间复杂度O(nlogS) #include <bits/stdc++.h> using namespace std; ; int a[N]; int…
C - Putting Boxes Together 思路: 求带权中位数 用树状数组维护修改 代码: #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize(4) #include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pi acos(-1.0) #define LL long long //…
E. Pencils and Boxes time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mishka received a gift of multicolored pencils for his birthday! Unfortunately he lives in a monochrome world, where ev…