답안 #169506

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
169506 2019-12-20T17:56:14 Z combi1k1 Semiexpress (JOI17_semiexpress) C++14
100 / 100
277 ms 33348 KB
#include<bits/stdc++.h>

using namespace std;

#define all(x)  x.begin(),x.end()
#define sz(x)   (int)x.size()

#define pb  emplace_back
#define ll  long long

int main()  {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int n, m, k;    cin >> n >> m >> k;
    ll  A, B, C;    cin >> A >> B >> C;

    ll  T;  cin >> T;

    vector<int> s(m);
    vector<ll>  pot;

    for(int i = 0 ; i < m ; ++i)    cin >> s[i];    s.pb(n + 1);
    for(int i = 0 ; i < m ; ++i)    {
        ll  rem = T - B * (s[i] - 1);
        int rig = s[i];

        if (rem < 0)    {
            pot.pb(n);
            continue;
        }
        int Q = 1;

        for(int j = 0 ; j < k ; ++j)    {
            ll  nxt = rig + rem / A + 1;

            if (nxt > s[i + 1])
                nxt = s[i + 1];

            ll  len = nxt - rig;
            pot.pb(len + Q * n);    Q = 0;

            rig += len;
            rem -= len * C;

            if (rem < 0)            break;
            if (rig == s[i + 1])    break;
        }
    }

    sort(pot.begin(),pot.end(),greater<ll>());

    if (k > sz(pot))
        k = sz(pot);

    cout << accumulate(pot.begin(),pot.begin() + k,0ll) - 1ll * m * n - 1 << endl;
}
/*
300 8 16
345678901 123456789 234567890
12345678901
1
10
77
82
137
210
297
300
*/

Compilation message

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:23:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for(int i = 0 ; i < m ; ++i)    cin >> s[i];    s.pb(n + 1);
     ^~~
semiexpress.cpp:23:53: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
     for(int i = 0 ; i < m ; ++i)    cin >> s[i];    s.pb(n + 1);
                                                     ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 372 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 372 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 11 ms 2548 KB Output is correct
22 Correct 8 ms 1528 KB Output is correct
23 Correct 77 ms 8692 KB Output is correct
24 Correct 37 ms 4588 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 133 ms 16852 KB Output is correct
28 Correct 277 ms 33348 KB Output is correct
29 Correct 68 ms 4708 KB Output is correct
30 Correct 25 ms 2544 KB Output is correct