Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define int long long
- #define fastio ios_base::sync_with_stdio(0); cin.tie(0)
- signed main()
- {
- fastio;
- /*
- //Junior B
- int n , k;
- cin >> n >> k;
- cout << min(n % k , k - n % k);
- */
- /*
- //Junior A
- int n , k;
- cin >> n >> k;
- int x = k / n , y = k % n;
- int sum = 0;
- if(x > 0){
- sum += k - n;
- }
- if(x < n - 1){
- sum += k + n;
- }
- if(y > 0){
- sum += k - 1;
- }
- if(y < n - 1){
- sum += k + 1;
- }
- cout << sum;
- */
- /*
- 0 1 2 3
- 4 5 6 7
- 8 9 10 11
- 12 13 14 15
- */
- /*
- // Junior C
- int n , m;
- cin >> n >> m;
- m -= n;
- int a[n + 5];
- multiset<pair<int , pair<int , int> > > ms;
- for(int i = 0; i < n; i++){
- cin >> a[i];
- if(i > 0)
- ms.insert({a[i] + a[i - 1] , {a[i - 1] , a[i]}});
- }
- // 1 2
- // 1 3 2
- // sum = 3 , l = 1 , r = 2
- while(m--){ // m defe
- auto it = ms.begin();
- int sum = (*it).F;
- int l = (*it).S.F , r = (*it).S.S;
- ms.erase(it);
- ms.insert({sum + l , {l , sum}});
- ms.insert({sum + r , {sum , r}});
- }
- int ans = 0;
- for(auto i : ms){
- ans = max({ans , i.S.F , i.S.S});
- }
- cout << ans;
- */
- /*
- //Junior D
- string s;
- cin >> s;
- int k;
- cin >> k;
- int n = s.size();
- bool used[n + 5] = {0};
- int cnt = 0;
- for(int i = 0; i + i < n; i++){
- if(s[i] != s[n - i - 1]){
- cnt++;
- if(s[i] < s[n - i - 1])
- s[i] = s[n - i - 1];
- else
- s[n - i - 1] = s[i];
- used[i] = 1;
- }
- }
- if(cnt > k){
- cout << ":(";
- return 0;
- }
- k -= cnt;
- for(int i = 0; i + i < n; i++){
- if(s[i] == 'z')
- continue;
- if(used[i] && k > 0){
- s[i] = 'z';
- s[n - i - 1] = 'z';
- k--;
- }
- int say = 1;
- if(i != n - i - 1)
- say++;
- if(k >= say){
- s[i] = 'z';
- s[n - i - 1] = 'z';
- k -= say;
- }
- }
- cout << s << '\n';
- */
- /*
- // Senior A
- int n , s , m , q;
- cin >> n >> s;
- int ans = 0; // qalan qepiklerin sayi
- bool ok = 0; // tort ala bileremmi?
- for(int i = 0; i < n; i++){
- cin >> m >> q;
- if(m * 100 + q <= s * 100){
- ok = 1;
- if(q != 0)
- ans = max(ans , 100 - q);
- }
- }
- if(ok == 0){ // ala bilmiremse
- cout << -1;
- return 0;
- }
- cout << ans;
- */
- /*
- // Senior B
- int n , k;
- cin >> n;
- bool used[n + 1] = {0};
- for(int i = 0; i < n; i++){
- cin >> k;
- used[k] = 1;
- }
- for(int i = 1; i <= n; i++){
- if(used[i] == 0){
- cout << i;
- return 0;
- }
- }
- cout << -1;
- */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement