Submission #55511461
Source Code Expand
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace chrono;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Aliases to op
using ll = long long;
using ull = unsigned long long;
using ld = double;
// Constants
constexpr ll INF = 4e18;
constexpr ld EPS = 1e-9;
constexpr ll MOD = 1e9+7;
// Macros
#define F first
#define S second
#define all(x) begin(x), end(x)
#define allr(x) rbegin(x), rend(x)
typedef vector<int> vi;
typedef pair<int,int> pi;
// #define insert push_back
#define pb push_back
#define MP make_pair
#define endl '\n'
#define rep(i,a,b) for (int i = a; i < b; i++)
const ll mod = 1e9+7;
ll inv(ll i) {if (i == 1) return 1; return (mod - ((mod / i) * inv(mod % i)) % mod) % mod;}
ll mod_mul(ll a, ll b) {a = a % mod; b = b % mod; return (((a * b) % mod) + mod) % mod;}
ll mod_add(ll a, ll b) {a = a % mod; b = b % mod; return (((a + b) % mod) + mod) % mod;}
ll mod_sub(ll a, ll b) {a = a % mod; b = b % mod; return (((a - b + mod) % mod) + mod) % mod;}
ll ceil_div(ll a, ll b) {return a % b == 0 ? a / b : a / b + 1;}
ll pwr(ll a, ll b) {a %= mod; ll res = 1; while (b > 0) {if (b & 1) res = res * a % mod; a = a * a % mod; b >>= 1;} return res;}
vector<ll> sieve(int n) {int*arr = new int[n + 1](); vector<ll> vect; for (int i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1;} return vect;}
template <typename T> // cin >> vector<T>
istream &operator>>(istream &istream, vector<T> &v)
{
for (auto &it : v)
cin >> it;
return istream;
}
template <typename T> // cout << vector<T>
ostream &operator<<(ostream &ostream, const vector<T> &c)
{
for (auto &it : c)
cout << it << " ";
return ostream;
}
// Mathematical functions
int GCD(int a, int b)
{
while (b)
{
a %= b;
swap(a, b);
}
return a;
}
int GCD_extended(int a, int b, int &x, int &y)
{
x = 1, y = 0;
int x1 = 0, y1 = 1, a1 = a, b1 = b;
while (b1)
{
int q = a1 / b1;
tie(x, x1) = make_tuple(x1, x - q * x1);
tie(y, y1) = make_tuple(y1, y - q * y1);
tie(a1, b1) = make_tuple(b1, a1 - q * b1);
}
return a1;
}
int LCM(int a, int b)
{
return ((ll)a * b) / GCD(a, b);
}
ll modpow(ll x, ll n, int m = MOD)
{
if (x == 0 && n == 0)
return 0; // undefined case
ll res = 1;
while (n > 0)
{
if (n % 2)
res = (res * x) % m;
x = (x * x) % m;
n /= 2;
}
return res;
}
int modinv(int x, int m = MOD)
{
return modpow(x, m - 2, m);
}
mt19937 rng;
int getRandomNumber(int l, int r)
{
uniform_int_distribution<int> dist(l, r);
return dist(rng);
}
// bool cmp(pair<ll, ll>& a,
// pair<ll, ll>& b)
// {
// return a.first < b.first;
// }
ll binToDec(string s) { return bitset<64>(s).to_ullong(); }
string decToBin(ll a) { return bitset<64>(a).to_string(); }
ll andOperator(ll a, ll b)
{
ll shiftcount = 0;
while (a != b and a > 0)
{
shiftcount++;
a = a >> 1;
b = b >> 1;
}
return int64_t(a << shiftcount);
}
ll factorial(ll n){
if (n==0){
return 1;
}
ll ans=1;
for (ll i=1;i<=n;i++){
ans=mod_mul(ans,i);
}
return ans;
}
ll lcm(ll a,ll b){
ll g=__gcd(a,b);
return (a*b/g);
}
ll helper(ll x){
ll d=sqrtl(x);
if (d*d==x){
return d;
}
else{
return d+1;
}
}
bool isPrime(ll n)
{
if (n <= 1)
return true;
for (int i = 2; i * i <= n; i++) {
if (n % i == 0)
return false;
}
return true;
}
long long int power(int base, int exp)
{
if (exp == 0)
return 1;
else if (exp == 1)
return base;
else
{
long long int calc;
if (exp % 2 == 0)
{
calc = power(base, exp/2);
calc *= calc;
}
else
{
calc = base*power(base, exp-1);
}
return calc;
}
}
class Compare {
public:
bool operator()(pair<int,int> a, pair<int,int> b)
{
int diff=a.second-a.first;
int diff2=b.second-b.first;
if (diff == diff2) {
return a.first>b.first;
}
return diff<diff2;
}
};
bool get(ll a,ll b, ll x){
if (a<b){
swap(a,b);
}
if (x==a || x==b){
return true;
}
if (a==0 || b==0){
return false;
}
return get(a%b,b,x);
}
long long binpow(long long a, long long b, long long m) {
a %= m;
long long res = 1;
while (b > 0) {
if (b & 1)
res = res * a % m;
a = a * a % m;
b >>= 1;
}
return res;
}
// vector<ll>a(200200);
// struct node{
// ll sum;
// ll lazy_add;
// ll lazy_set;
// node(){
// sum=0;
// lazy_add=0;
// lazy_set=0;
// }
// };
// node t[4*200200];
// node merge(node a,node b){
// node ans;
// ans.sum=a.sum+b.sum;
// return ans;
// }
// void push_down(ll id,ll child){
// if (t[id].lazy_set!=0){
// t[child].lazy_set=t[id].lazy_set;
// t[child].lazy_add=0;
// }
// else{
// if (t[child].lazy_set!=0){
// t[child].lazy_set+=t[id].lazy_add;
// }
// else{
// t[child].lazy_add+=t[id].lazy_add;
// }
// }
// }
// void push(ll id,ll l,ll r){
// if (t[id].lazy_add==0 && t[id].lazy_set==0){
// return;
// }
// if (l!=r){
// push_down(id,2*id);
// push_down(id,2*id+1);
// }
// if (t[id].lazy_add!=0){
// t[id].sum+=(r-l+1)*t[id].lazy_add;
// }
// else if (t[id].lazy_set!=0){
// t[id].sum=(r-l+1)*t[id].lazy_set;
// }
// t[id].lazy_set=0;
// t[id].lazy_add=0;
// }
// void build(ll id,ll l,ll r){
// if (l==r){
// // cout << id << " " << a[l] << " " << l << endl;
// t[id].sum=a[l];
// t[id].lazy_add=0;
// t[id].lazy_set=0;
// return;
// }
// ll mid=(l+r)/2;
// build(2*id,l,mid);
// build(2*id+1,mid+1,r);
// t[id]=merge(t[2*id],t[2*id+1]);
// }
// void update(ll id,ll l,ll r,ll lq,ll rq,ll val,ll ch){
// push(id,l,r);
// if (lq>r || rq<l){
// return;
// }
// if (lq<=l && r<=rq){
// if (ch==1){
// t[id].lazy_add+=val;
// }
// else{
// t[id].lazy_set=val;
// }
// push(id,l,r);
// return;
// }
// ll mid=(l+r)/2;
// update(2*id,l,mid,lq,rq,val,ch);
// update(2*id+1,mid+1,r,lq,rq,val,ch);
// t[id]=merge(t[2*id],t[2*id+1]);
// }
// node query(ll id,ll l,ll r,ll lq,ll rq){
// push(id,l,r);
// if (lq>r || rq<l){
// return node();
// }
// if (lq<=l && r<=rq){
// return t[id];
// }
// ll mid=(l+r)/2;
// return merge(query(2*id,l,mid,lq,rq),query(2*id+1,mid+1,r,lq,rq));
// }
bool sortbysec(const pair<ll,ll> a,
const pair<ll,ll> b)
{
ll sum=a.first+a.second;
ll sum2=b.first+b.second;
return sum>sum2;
}
ll nCr(ll n, ll r,vector<ll>&f) {
if (n<r){
return 0;
}
ll ans=f[n];
// ans=mod_mul(ans,inv(f[r]));
ans=mod_mul(ans,inv(f[n-r]));
return ans;
}
ll mysqrt(ll n){
ll ans=0;
ll low=1;
ll high=1e9;
while(low<=high){
ll md=(low+high)/2;
if (md*md<=n){
ans=md;
low=md+1;
}
else{
high=md-1;
}
}
return ans;
}
// const int ALPHABET_SIZE = 26;
// string key;
// struct TrieNode
// {
// struct TrieNode *children[ALPHABET_SIZE];
// bool isEndOfWord; // represent end of word
// };
// struct TrieNode *getNode(void)
// {
// struct TrieNode *pNode = new TrieNode;
// pNode->isEndOfWord = false;
// for (int i = 0; i < ALPHABET_SIZE; i++)
// pNode->children[i] = NULL;
// return pNode;
// }
// void insert(struct TrieNode *root, int idx)
// {
// struct TrieNode *pCrawl = root;
// for (int i = idx; i < key.length(); i++)
// {
// int index = key[i] - 'a';
// if (!pCrawl->children[index])
// pCrawl->children[index] = getNode();
// pCrawl = pCrawl->children[index];
// }
// // mark last node as leaf
// pCrawl->isEndOfWord = true;
// }
// struct TrieNode *search(struct TrieNode *root, string key)
// {
// struct TrieNode *pCrawl = root;
// for (int i = 0; i < key.length(); i++)
// {
// int index = key[i] - 'a';
// if (!pCrawl->children[index])
// return NULL;
// pCrawl = pCrawl->children[index];
// }
// return pCrawl;
// }
// void dfs(struct TrieNode *curNode, string curString, vector<string> &res)
// {
// for(int letter = 0; letter < ALPHABET_SIZE; letter++)
// {
// if(curNode->children[letter] != NULL)
// {
// string tmp = curString;
// tmp.push_back(letter + 'a');
// dfs(curNode->children[letter], tmp, res);
// }
// }
// if(curNode->isEndOfWord)
// res.push_back(curString);
// }
void solve(){
ll r,g,b;
cin>>r>>g>>b;
string s;
cin>>s;
if (s=="Blue"){
cout << min(r,g) << endl;
}
if (s=="Red"){
cout << min(g,b) << endl;
}
if (s=="Green"){
cout << min(r,b) << endl;
}
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int T;
// cin>>T;
// spfsieve();
T=1;
auto start1 = high_resolution_clock::now();
while(T--){
solve();
}
auto stop1 = high_resolution_clock::now();
auto duration = duration_cast<microseconds>(stop1 - start1);
cerr << "Time: " << duration . count() / 1000 << " ms" << endl;
return 0;
}
Submission Info
| Submission Time |
|
| Task |
A - Buy a Pen |
| User |
an1ket_62 |
| Language |
C++ 20 (gcc 12.2) |
| Score |
100 |
| Code Size |
10583 Byte |
| Status |
AC |
| Exec Time |
1 ms |
| Memory |
3596 KiB |
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
100 / 100 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
| All |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt |
| Case Name |
Status |
Exec Time |
Memory |
| 00_sample_00.txt |
AC |
1 ms |
3404 KiB |
| 00_sample_01.txt |
AC |
1 ms |
3520 KiB |
| 00_sample_02.txt |
AC |
1 ms |
3336 KiB |
| 01_random_00.txt |
AC |
1 ms |
3576 KiB |
| 01_random_01.txt |
AC |
1 ms |
3596 KiB |
| 01_random_02.txt |
AC |
1 ms |
3488 KiB |
| 01_random_03.txt |
AC |
1 ms |
3468 KiB |
| 01_random_04.txt |
AC |
1 ms |
3420 KiB |
| 01_random_05.txt |
AC |
1 ms |
3420 KiB |
| 01_random_06.txt |
AC |
1 ms |
3592 KiB |
| 01_random_07.txt |
AC |
1 ms |
3584 KiB |
| 01_random_08.txt |
AC |
1 ms |
3436 KiB |
| 01_random_09.txt |
AC |
1 ms |
3440 KiB |
| 01_random_10.txt |
AC |
1 ms |
3592 KiB |
| 01_random_11.txt |
AC |
1 ms |
3484 KiB |
| 01_random_12.txt |
AC |
1 ms |
3580 KiB |