QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#94519#5259. Skills in Pillsmaomao90#WA 2ms3540kbC++171.7kb2023-04-06 15:27:512023-04-06 15:27:52

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-06 15:27:52]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3540kb
  • [2023-04-06 15:27:51]
  • 提交

answer


// Hallelujah, praise the one who set me free
// Hallelujah, death has lost its grip on me
// You have broken every chain, There's salvation in your name
// Jesus Christ, my living hope
#include <bits/stdc++.h> 
using namespace std;

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define RREP(i, s, e) for (int i = (s); i >= (e); i--)
template <class T>
inline bool mnto(T& a, T b) {return a > b ? a = b, 1 : 0;}
template <class T>
inline bool mxto(T& a, T b) {return a < b ? a = b, 1: 0;}
typedef long long ll;
typedef long double ld;
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> iii;
#define ALL(_a) _a.begin(), _a.end()
#define SZ(_a) (int) _a.size()
#define pb push_back
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<iii> viii;

#ifndef DEBUG
#define cerr if (0) cerr
#endif

const int INF = 1000000005;
const ll LINF = 1000000000000000005ll;
const int MAXN = 1000005;

int x, y, n;
ii dp[MAXN];
int ans;

int main() {
#ifndef DEBUG
    ios::sync_with_stdio(0), cin.tie(0);
#endif
    cin >> x >> y >> n;
    if (x > y) {
        swap(x, y);
    }
    dp[0] = {0, 0};
    REP (i, 1, n + 1) {
        dp[i] = {INF, INF};
        REP (j, max(i - x, 0), i - x + 2) {
            ii tmp = dp[j];
            tmp.FI++;
            if (i + 1 + tmp.SE > y) {
                tmp.FI++;
                tmp.SE = -(i - 1);
            }
            mnto(dp[i], tmp);
        }
    }
    ans = INF;
    REP (i, n - x + 1, n) {
        ii tmp = dp[i];
        if (n + tmp.SE >= y) {
            tmp.FI++;
            tmp.SE = -(i - 1);
        }
        mnto(ans, tmp.FI);
    }
    cout << ans << '\n';
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3348kb

input:

3 9 20

output:

8

result:

ok single line: '8'

Test #2:

score: 0
Accepted
time: 2ms
memory: 3420kb

input:

8 2 12

output:

7

result:

ok single line: '7'

Test #3:

score: 0
Accepted
time: 2ms
memory: 3284kb

input:

2 5 15

output:

10

result:

ok single line: '10'

Test #4:

score: 0
Accepted
time: 2ms
memory: 3540kb

input:

10 8 13

output:

2

result:

ok single line: '2'

Test #5:

score: -100
Wrong Answer
time: 2ms
memory: 3324kb

input:

6 6 19

output:

5

result:

wrong answer 1st lines differ - expected: '6', found: '5'