답안 #709461

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
709461 2023-03-13T16:05:32 Z aedmhsn 걷기 (NOI12_walking) C++17
20 / 25
12 ms 22084 KB
#include <bits/stdc++.h>
using namespace std;
 
#define A first
#define B second
#define MP make_pair
#define ms(a, x) memset(a, x, sizeof(a)) 
 
 
#define boost() ios_base::sync_with_stdio(false); cin.tie(NULL)
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long double, long double> pld;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);

const int mxN=1e4+1e3+5;

int dp[505][mxN], l, n;
vector <pii> v;

ll solve(int pos, int range){
    if(pos == n)
        return 0;
    if(dp[pos][range] != -1)
        return dp[pos][range];
    ll ret = solve(pos+1, range);
    if(v[pos].B < range)
        ret = max(ret, solve(pos+1, v[pos].B)+1);
    return dp[pos][range]=ret;
}

int main(){
    ms(dp, -1);
    cin >> l >> n;
    for(int i=0; i<n; i++){
        int x, y;
        cin >> x >> y;
        v.push_back({x, l/y + x + (l/y % 2)});
    } 
    sort(v.begin(), v.end());
    cout << solve(0, mxN-5);
}

// 3 1 2 1 1
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 22036 KB Output is correct
2 Correct 9 ms 21972 KB Output is correct
3 Correct 9 ms 21972 KB Output is correct
4 Correct 12 ms 21972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 22052 KB Output is correct
2 Correct 10 ms 21972 KB Output is correct
3 Correct 9 ms 21972 KB Output is correct
4 Correct 9 ms 21972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 21972 KB Output is correct
2 Correct 11 ms 21948 KB Output is correct
3 Incorrect 9 ms 21972 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 21972 KB Output is correct
2 Correct 10 ms 21972 KB Output is correct
3 Correct 10 ms 21972 KB Output is correct
4 Correct 10 ms 21972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 22084 KB Output is correct
2 Correct 10 ms 21972 KB Output is correct
3 Correct 10 ms 21980 KB Output is correct
4 Correct 10 ms 22024 KB Output is correct