kziborov3's blog

By kziborov3, history, 4 hours ago, In Russian

Thank you for participating in the first ever Serbian Div. 3 Codeforces round!

Sorry Also a massive thanks to Vladosiya for giving us a chance to create a divison 3 round!

1878A — How Much Does Daytona Cost?

Problem was authored and prepared by Author: wxhtzdy

Prepared by: ognjentesic, AndrewPav, AlphaMale06

Hints Hint 1 When is the answer definitely "NO"?

Hint 2 What happens if there is no element equal to k in the array?

Hint 3 What happens if there is an element equal to k in the array?

Tutorial 1878A — How Much Does Daytona Cost? It's enough to check if there even exists the element equals to K , since K is obviously the most common element in the subsegment of length 1 which contains it.

Solution

include <bits/stdc++.h>

using namespace std;

int main(){ int t; //read the number of test cases cin >> t; while(t--){ int n, k; cin >> n >> k; //read n and k bool ys=0; //bool value if true then there exists a subsegment which satisfies the condition, else it doesn't exist for(int i=0; i< n; i++){ int a; //read the i-th element of the array cin >> a; if(a==k)ys=1; //if the element is equal to k, then the subsegment [i, i] has the most common element equal to k } if(ys)cout << "YES\n"; //output the answer else cout << "NO\n"; } }

  • Vote: I like it
  • 0
  • Vote: I do not like it