8.23-河西校区

· · 个人记录

8.23-河西校区

::::::info[T1]{open}

T640710 高铁线路

::::success[赛时代码&得分]

\color{green}{Accepted\not100tps}
#include <bits/stdc++.h>
using namespace std;
int n, x, y, z;
signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> x >> y >> z;
    if (x > y) {
        if (z > x || z < y) 
            cout << "No";
        else if (z <= x && z >= y) 
            cout << "Yes";
    } else if (x < y) {
        if (z < x || z > y) 
            cout << "No";
        else if (z >= x && z <= y) 
            cout << "Yes";
    } else {
        if (z != x) 
            cout << "No";
        else 
            cout << "Yes";
    }
    return 0;
}
::::

::::::info[T2]{open}

U591726 盲打练习

::::success[赛时代码&得分]

\color{green}{Accepted\not100tps}
#include <bits/stdc++.h>
using namespace std;
string s, t;
signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> s >> t;
    int lens = s.size(), lent = t.size();
    for (int i = 0, j = 0; i < lens && j < lent; ) {
        if (s[i] == t[j]) {
            i ++;
            j ++;
            cout << j << " ";
        } else if (s[i] != t[j]) 
            j ++;
    }
    return 0;
}
::::

::::::info[T3]{open}

T639117 Int128 游乐园

::::success[赛时代码&得分]

\color{green}{Accepted\not100tps}
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int n, k, x, cur, ans;
queue<int> q;
signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i ++) {
        cin >> x;
        q.push(x);
    }
    cur = k;
    while (!q.empty()) {
        x = q.front();
        if (x <= cur) {
            cur -= x;
            q.pop();
        } else {
            ans ++;
            cur = k;
        }
//      cout << "x: " << x << " cur:" << cur << " q.size(): " << q.size() << " ans: " << ans << "\n";
    }
    if (cur != k) 
        ans ++;
    cout << ans;
    return 0;
}
::::

::::::info[T4]{open}

T639126 落落的去的数学问题2

::::warning[赛时得分]

\color{red}{Unaccepted\not10tps}

:::: ::::success[正解]

#include <bits/stdc++.h>
#define int long long 
using namespace std;
const int N = 3e5 + 5, mod = 1e8;
int n, cnt, sum;
int a[N];
signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i ++) 
        cin >> a[i];
    sort(a + 1, a + 1 + n);
    for (int i = 1; i <= n; i ++) {
        sum += a[i];
        int pos = lower_bound(a + i + 1, a + 1 + n, mod - a[i]) - a;
        cnt += n - pos + 1;
    }
    cout << sum * (n - 1) - cnt * mod;
    return 0;
}
::::

::::::info[T5]{open}

T638485 第K小

::::warning[赛时得分]

\color{red}{Unaccepted\not10tps}

:::: ::::success[正解]

#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int n, k, cnt;
ll a[16];
map<ll, ll> mp;
priority_queue<ll, vector<ll>, greater<ll> >q;
signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i ++) {
        cin >> a[i];
        if (mp[a[i]]) 
            continue;
        q.push(a[i]);
        mp[a[i]] = 1;
    }
    while (q.size()) {
        cnt ++; 
        ll _ = q.top();
        if (cnt == k) {
            cout << q.top();
            return 0;
        }
        q.pop();
        for (int i = 1; i <= n; i ++) {
            if (mp[_ + a[i]]) 
                continue;
            mp[_ + a[i]] = 1;
            q.push(_ + a[i]);
        }
    }
    cout << cnt;
    return 0;
}
::::

::::::info[T6]{open}

U591734 磁铁迷宫

::::warning[赛时得分]

\color{red}{Unaccepted\not0pts}

:::: ::::success[正解]

#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int n, k, cnt;
ll a[16];
map<ll, ll> mp;
priority_queue<ll, vector<ll>, greater<ll> >q;
signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i ++) {
        cin >> a[i];
        if (mp[a[i]]) 
            continue;
        q.push(a[i]);
        mp[a[i]] = 1;
    }
    while (q.size()) {
        cnt ++; 
        ll _ = q.top();
        if (cnt == k) {
            cout << q.top();
            return 0;
        }
        q.pop();
        for (int i = 1; i <= n; i ++) {
            if (mp[_ + a[i]]) 
                continue;
            mp[_ + a[i]] = 1;
            q.push(_ + a[i]);
        }
    }
    cout << cnt;
    return 0;
}
::::