Блог пользователя Sinux

Автор Sinux, история, 2 месяца назад, По-английски

Since I am a newbie. I want to know how you guys practice solving problems. Do you guys practice by solving the problemset or by participating virtual contests? Any other advices are welcome.

Полный текст и комментарии »

  • Проголосовать: нравится
  • -1
  • Проголосовать: не нравится

Автор Sinux, история, 4 месяца назад, По-английски

Hi, I was practicing solving problems from USACO and I became curious when I saw the test data. The majority of the test data have surprisingly large numbers of test data. How are these test cases made? Do the problems maker calculate the output with these unusually large numbers of inputs?(Sorry for the bad english)

Полный текст и комментарии »

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

Автор Sinux, история, 4 месяца назад, По-английски

I am struggling on solving the problem 1873E problem div4. I wrote the solution but few test cases are wrong and I can't find the flaw in my code. Plz Help!!!

#include <algorithm>
#include <iostream> 
#include <vector> 
using namespace std;
#define ll long long
int main() {
    ll t;
    cin >> t;
    while (t--) {
        ll n, x;
        cin >> n >> x;
        vector<ll> a(n);
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        sort(a.begin(), a.end());
        ll left = 0, right = a[n - 1];
        ll height = 0;
        while (left <= right) {
            ll mid = (left + right) / 2;
            ll sum = 0;
            for (int i = 0; i < n; i++) {
                if (mid > a[i]) {
                    sum += mid - a[i];
                }
            }
            if (sum <= x) {
                height = mid;
                left = mid + 1;
            }
            else {
                right = mid - 1;
            }
        }
        cout << height << '\n'; 
    }

    return 0;
}

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор Sinux, история, 4 месяца назад, По-английски

void search(int k) { if (k == n) { // process subset } else { search(k+1); subset.push_back(k); search(k+1); subset.pop_back(); } }

I am having a really hard time understand this code. I especially don't understand how 'k' turns to 2 after 'k' reaches 3. I don't understand because there's no such code that does search(k-1) but it backtracks automatically. I think It's related to the thing backtracking. Someone plz help!!!

Полный текст и комментарии »

  • Проголосовать: нравится
  • +6
  • Проголосовать: не нравится

Автор Sinux, история, 5 месяцев назад, По-английски

Should I practice CP by problems rating or by algorithm topics?

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор Sinux, история, 5 месяцев назад, По-английски

Hi, I am curious. At what age do successful competitive programmers such as IOI gold medal winners start CP?

Полный текст и комментарии »

  • Проголосовать: нравится
  • +6
  • Проголосовать: не нравится

Автор Sinux, история, 5 месяцев назад, По-английски

Hey guys, I just started CP. I am able to solve 800 rated problems very easily but find 900 rated problems hard(especially number theory or math problems). I am currently in 8th grade and studying algebra 1. I am curious if the lack of my high school math skill is the reason solving 900 rated problems very hard.

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится