codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

1119.md (3024B)


      1 Source: https://codeforces.com/blog/entry/66411
      2 
      3 [1119A - Ilya and a Colorful Walk](/contest/1119/problem/A "Codeforces Global Round 2")
      4 
      5 Author, preparation: [300iq](/profile/300iq "International Grandmaster 300iq").
      6 
      7 **Editorial**
      8 
      9 Tutorial is loading...
     10 
     11 [1119B - Alyona and a Narrow Fridge](/contest/1119/problem/B "Codeforces Global Round 2")
     12 
     13 Author, preparation: [KAN](/profile/KAN "Grandmaster KAN").
     14 
     15 **Editorial with bonuses**
     16 
     17 Tutorial is loading...
     18 
     19 [Aleks5d](/profile/Aleks5d "Master Aleks5d") invites you to compete in the shortest solution challenge for this problem. His code (155 bytes):
     20 
     21 **Code**
     22 
     23 ```
     24 [n, k], arr = [int(i) for i in input().split()], [int(i) for i in input().split()]
     25 print([i for i in range(n + 1) if sum(sorted(arr[0:i])[::-2]) <= k][-1])
     26 ```
     27 
     28 **Authors during the contest**
     29 
     30 ![ ](/predownloaded/bd/6d/bd6d1956df48f7d081647430194b5adfbd2eb11f.jpg)
     31 
     32 [1119C - Ramesses and Corner Inversion](/contest/1119/problem/C "Codeforces Global Round 2")
     33 
     34 Author, preparation: [300iq](/profile/300iq "International Grandmaster 300iq").
     35 
     36 **Editorial**
     37 
     38 Tutorial is loading...
     39 
     40 [1119D - Frets On Fire](/contest/1119/problem/D "Codeforces Global Round 2")
     41 
     42 Author, preparation: [cyand1317](/profile/cyand1317 "Grandmaster cyand1317").
     43 
     44 **Editorial**
     45 
     46 Tutorial is loading...
     47 
     48 **Code**
     49 
     50 ```
     51 #include <cstdio>
     52 #include <algorithm>
     53 
     54 static const int MAXN = 1e5;
     55 
     56 static int n, q;
     57 static long long s[MAXN];
     58 static long long t[MAXN];
     59 
     60 int main()
     61 {
     62     scanf("%d", &n);
     63     for (int i = 0; i < n; ++i) scanf("%lld", &s[i]);
     64 
     65     std::sort(s, s + n);
     66     for (int i = 0; i < n - 1; ++i) s[i] = s[i + 1] - s[i];
     67     std::sort(s, s + n - 1);
     68     for (int i = n - 1; i >= 1; --i) s[i] = s[i - 1];
     69     s[0] = 0;
     70     for (int i = 1; i < n; ++i)
     71         t[i] = t[i - 1] + (s[i] - s[i - 1]) * (n + 1 - i);
     72 
     73     scanf("%d", &q);
     74     for (int i = 0; i < q; ++i) {
     75         long long l, r;
     76         scanf("%lld%lld", &l, &r);
     77         l = r - l + 1;
     78         int p = std::lower_bound(s, s + n, l) - &s[0] - 1;
     79         printf("%lld%c", t[p] + (l - s[p]) * (n - p), i == q - 1 ? '\n' : ' ');
     80     }
     81 
     82     return 0;
     83 }
     84 ```
     85 
     86 [1119E - Pavel and Triangles](/contest/1119/problem/E "Codeforces Global Round 2")
     87 
     88 Author: [gen](/profile/gen "Master gen"), preparation: [300iq](/profile/300iq "International Grandmaster 300iq").
     89 
     90 **Editorial**
     91 
     92 Tutorial is loading...
     93 
     94 [1119F - Niyaz and Small Degrees](/contest/1119/problem/F "Codeforces Global Round 2")
     95 
     96 Author, preparation: [300iq](/profile/300iq "International Grandmaster 300iq").
     97 
     98 **Editorial**
     99 
    100 Tutorial is loading...
    101 
    102 [1119G - Get Ready for the Battle](/contest/1119/problem/G "Codeforces Global Round 2")
    103 
    104 Authors: [Aleks5d](/profile/Aleks5d "Master Aleks5d"), [KAN](/profile/KAN "Grandmaster KAN"); preparation: [Aleks5d](/profile/Aleks5d "Master Aleks5d").
    105 
    106 **Editorial**
    107 
    108 Tutorial is loading...
    109 
    110 [1119H - Triple](/contest/1119/problem/H "Codeforces Global Round 2")
    111 
    112 Author, preparation: [RDDCCD](/profile/RDDCCD "Grandmaster RDDCCD").
    113 
    114 **Editorial**
    115 
    116 Tutorial is loading...