CodeForces 709A Juicer (水题, 模拟)

题意:给定 n 个桔子的大小,一个杯子的容积,一个最大限度,挨着挤桔子汁,如果大小大于限度,扔掉,如果不杯子满了倒掉,问你要倒掉多少杯。

析:直接按要求模拟就好,满了就清空杯子。

代码如下:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std;

typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 1e5 + 5;
const int mod = 1e8;
const char *mark = "+-*";
const int dr[] = {-1, 0, 1, 0, 1, 1, -1, -1};
const int dc[] = {0, 1, 0, -1, -1, 1, 1, -1};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline int Min(int a, int b){ return a < b ? a : b; }
inline int Max(int a, int b){ return a > b ? a : b; }
inline LL Min(LL a, LL b){ return a < b ? a : b; }
inline LL Max(LL a, LL b){ return a > b ? a : b; }
inline bool is_in(int r, int c){
    return r >= 0 && r < n && c >= 0 && c < m;
}

int main(){
    LL b, d;
    cin >> n >> b >> d;
    LL x, sum = 0;
    int ans = 0;
    for(int i = 0; i < n; ++i){
        cin >> x;
        if(x > b)   continue;
        sum += x;
        if(sum > d)  sum = 0, ++ans;
    }
    cout << ans << endl;
    return 0;
}
时间: 2024-08-26 11:13:05

CodeForces 709A Juicer (水题, 模拟)的相关文章

CodeForces 20B Equation 水题

题目链接:点击打开链接 #include <cstdio> #include <cstring> #include <algorithm> #include <vector> #include <iostream> #include <map> #include <set> #include <math.h> using namespace std; #define inf 10000000 #define l

CodeForces 705A Hulk (水题)

题意:输入一个 n,让你输出一行字符串. 析:很水题,只要判定奇偶性,输出就好. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream> #include <cstring

CodeForces 686A Free Ice Cream (水题模拟)

题意:给定初始数量的冰激凌,然后n个操作,如果是“+”,那么数量就会增加,如果是“-”,如果现有的数量大于等于要减的数量,那么就减掉,如果小于, 那么孩子就会离家.问你最后剩下多少冰激凌,和出走的孩子数量. 析:多水的一个题,就是一个模拟,如果是+,就加上,如果是‘-’,就判断一下,如果不够,就记录下来. 代码如下: #include <iostream> #include <cmath> #include <cstdlib> #include <set>

CodeForces 342B Xenia and Spies (水题模拟,贪心)

题意:给定 n 个间谍,m个区间,一个 s,一个f,然后从 s开始传纸条,然后传到 f,然后在每个 t 时间在区间内的不能传,问你最少的时间传过去. 析:这个题,就模拟一下就好,贪心策略,能传就传,找好方向,一直传就行,传到 f 就结束. 代码如下: #include <bits/stdc++.h> using namespace std; struct node{ int l, r, t; bool operator < (const node &p) const{ retur

CodeForces 731B Coupons and Discounts (水题模拟)

题意:有n个队参加CCPC,然后有两种优惠方式,一种是一天买再次,一种是买两天,现在让你判断能不能找到一种方式,使得优惠不剩余. 析:直接模拟,如果本次是奇数,那么就得用第二种,作一个标记,再去计算下一个. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #inclu

CodeForces 723B Text Document Analysis (水题模拟)

题意:给定一行字符串,让你统计在括号外最长的单词和在括号内的单词数. 析:直接模拟,注意一下在左右括号的时候有没有单词.碰到下划线或者括号表示单词结束了. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include

CodeForces 339B Xenia and Ringroad(水题模拟)

题意:给定 n 个地方,然后再给 m 个任务,每个任务必须在规定的地方完成,并且必须按顺序完成,问你最少时间. 析:没什么可说的,就是模拟,记录当前的位置,然后去找和下一个位置相差多长时间,然后更新当前位置即可. 代码如下: #include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; typedef long long LL; int main(){ int n, m, x; while(cin >>

ACM: NBUT 1105 多连块拼图 - 水题 - 模拟

NBUT 1105  多连块拼图 Time Limit:1000MS     Memory Limit:65535KB     64bit IO Format: Practice Appoint description:  System Crawler  (Aug 12, 2016 9:32:14 AM) Description 多连块是指由多个等大正方形边与边连接而成的平面连通图形. -- 维基百科 给一个大多连块和小多连块,你的任务是判断大多连块是否可以由两个这样的小多连块拼成.小多连块只能

CodeForces 709A Juicer

简单题. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vector> #include<map> #include<set> #include<queue> #inc