Submission #71081

# Submission time Handle Problem Language Result Execution time Memory
71081 2018-08-24T05:50:22 Z Inovak Long Distance Coach (JOI17_coach) C++14
0 / 100
4 ms 464 KB
#include <bits/stdc++.h>

#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define ll long long
#define OK puts("OK");
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 2e5+10;
const ll inf = 1e18+10;

ll x, n, m, w, t, ans;
ll s[N];
pair <ll, ll> p[N];
bool u[N];

int main() {
    cin >> x >> n >> m >> w >> t;
    for(int i = 1; i <= n; i++)
        scanf("%lld", &s[i]);

    for(int i = 1; i <= m; i++) {
        scanf("%lld%d", &p[i].fr, &p[i].sc);
        if(x > p[i].fr) {
            ll xx = x - p[i].fr;
            ans += w * ((xx / t) + 1);
        }
    }
    ans += w * ((x / t) + 1);

    sort(p + 1, p + m + 1);
    sort(s + 1, s + n + 1);
    p[++m] = mk(t, inf);
    s[++n] = x;

    for(int i = 1; i <= n; i++) {
        ll xx = s[i] % t, yy = s[i] / t;
        for(int j = m; j >= 1; j--) {
            if(u[j] || xx < p[j].fr) continue;
            if(p[j].sc > w * (((x - p[j].fr) / t) + 1 - yy)) break;
            u[j] = 1;
            ans -= w * (((x - p[j].fr) / t) + 1 - yy);
            ans += p[j].sc;
        }
    }
    cout << ans << endl;
}

Compilation message

coach.cpp: In function 'int main()':
coach.cpp:28:43: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
         scanf("%lld%d", &p[i].fr, &p[i].sc);
                                           ^
coach.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &s[i]);
         ~~~~~^~~~~~~~~~~~~~~
coach.cpp:28:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld%d", &p[i].fr, &p[i].sc);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 4 ms 464 KB Output is correct
3 Correct 3 ms 464 KB Output is correct
4 Correct 3 ms 464 KB Output is correct
5 Correct 2 ms 464 KB Output is correct
6 Incorrect 3 ms 464 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 4 ms 464 KB Output is correct
3 Correct 3 ms 464 KB Output is correct
4 Correct 3 ms 464 KB Output is correct
5 Correct 2 ms 464 KB Output is correct
6 Incorrect 3 ms 464 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 4 ms 464 KB Output is correct
3 Correct 3 ms 464 KB Output is correct
4 Correct 3 ms 464 KB Output is correct
5 Correct 2 ms 464 KB Output is correct
6 Incorrect 3 ms 464 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 4 ms 464 KB Output is correct
3 Correct 3 ms 464 KB Output is correct
4 Correct 3 ms 464 KB Output is correct
5 Correct 2 ms 464 KB Output is correct
6 Incorrect 3 ms 464 KB Output isn't correct
7 Halted 0 ms 0 KB -