Greedy Takahashi——UPC

简介: 题目描述Takahashi has A cookies, and Aoki has B cookies. Takahashi will do the following action K times:·If Takahashi has one or more cookies, eat one of his cookies.·Otherwise, if Aoki has one or more cookies, eat one of Aoki’s cookies.·If they both have no cookies, do nothing.

题目描述

Takahashi has A cookies, and Aoki has B cookies. Takahashi will do the following action K times:

·If Takahashi has one or more cookies, eat one of his cookies.

·Otherwise, if Aoki has one or more cookies, eat one of Aoki’s cookies.

·If they both have no cookies, do nothing.

In the end, how many cookies will Takahashi and Aoki have, respectively?


Constraints

·0≤A≤1012

·0≤B≤1012

·0≤K≤1012

·All values in input are integers.


输入


Input is given from Standard Input in the following format:


A B K


输出


Print the numbers of Takahashi’s and Aoki’s cookies after K actions.


样例输入


【样例1】
2 3 3
【样例2】
500000000000 500000000000 1000000000000


样例输出


【样例1】
0 2
【样例2】
0 0


提示


样例1解释

Takahashi will do the following:

·He has two cookies, so he eats one of them.

·Now he has one cookie left, and he eats it.

·Now he has no cookies left, but Aoki has three, so Takahashi eats one of them.

Thus, in the end, Takahashi will have 0 cookies, and Aoki will have 2.

———————————————————————————————————————

很水,直接放代码


#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define wuyt main
typedef long long ll;
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > >
template<class T> inline T min(T &x,const T &y){return x>y?y:x;}
template<class T> inline T max(T &x,const T &y){return x<y?y:x;}
//#define getchar()(p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 21) + 1], *p1 = buf, *p2 = buf;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();
if(c == '-')Nig = -1,c = getchar();
while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();
return Nig*x;}
#define read read()
const ll inf = 1e15;
const int maxn = 2e5 + 7;
const int mod = 1e9 + 7;
#define start int wuyt()
#define end return 0
start{
    ll a,b,k;
    cin>>a>>b>>k;
    if(k<=a) cout<<a-k<<" "<<b<<endl;
    else if(k<=a+b) cout<<0<<" "<<b+a-k<<endl;
    else cout<<0<<" "<<0<<endl;
    end;
}
/**************************************************************
    Language: C++
    Result: 正确
    Time:1 ms
    Memory:2024 kb
****************************************************************/


目录
相关文章
|
8月前
|
算法
hdoj 4712 Hamming Distance(靠人品过的)
在信息论中,两个等长字符串之间的汉明距离是两个字符串对应位置的字符不同的个数。换句话说,它就是将 一个字符串变换成另外一个字符串所需要替换的字符个数。
22 0
|
存储
LeetCode 187. Repeated DNA Sequences
所有 DNA 由一系列缩写为 A,C,G 和 T 的核苷酸组成,例如:“ACGAATTCCG”。在研究 DNA 时,识别 DNA 中的重复序列有时会对研究非常有帮助。 编写一个函数来查找 DNA 分子中所有出现超多一次的10个字母长的序列(子串)。
65 0
LeetCode 187. Repeated DNA Sequences
AtCoder Beginner Contest 221 D - Online games(差分 离散化 区间)
AtCoder Beginner Contest 221 D - Online games(差分 离散化 区间)
108 0
|
人工智能
Codeforces1343D - Constant Palindrome Sum + UPC-鸭子游戏 (差分)
Codeforces1343D - Constant Palindrome Sum + UPC-鸭子游戏 (差分)
77 1
|
人工智能 BI
AtCoder Beginner Contest 216 F - Max Sum Counting (降维 背包dp)
AtCoder Beginner Contest 216 F - Max Sum Counting (降维 背包dp)
104 0
|
人工智能
UPC-Match Matching(完全背包dp+字符串)
UPC-Match Matching(完全背包dp+字符串)
61 0
|
Windows
Prediction and Restriction——UPC
题目描述 At an arcade, Takahashi is playing a game called RPS Battle, which is played as follows: ·The player plays N rounds of Rock Paper Scissors against the machine. (See Notes for the description of Rock Paper Scissors. A draw also counts as a round.)
92 0
【1096】Consecutive Factors (20 分)
【1096】Consecutive Factors (20 分) 【1096】Consecutive Factors (20 分)
101 0
|
算法
泊松分布 (Poisson-Disc)算法
泊松分布 (Poisson-Disc)算法
287 0
泊松分布 (Poisson-Disc)算法

热门文章

最新文章