Submission #709473

# Submission time Handle Problem Language Result Execution time Memory
709473 2023-03-13T16:18:17 Z aedmhsn Walking (NOI12_walking) C++17
25 / 25
3 ms 1364 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=505;

int dp[mxN][mxN], n;
ld l;
vector <pair<int,ld>> 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(range == 504 || v[pos].B < v[range].B){
        ret = max(ret, solve(pos+1, pos)+1);
    }
    return dp[pos][range]=ret;
}

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

// 3 1 2
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1300 KB Output is correct
2 Correct 1 ms 1304 KB Output is correct
3 Correct 1 ms 1236 KB Output is correct
4 Correct 1 ms 1300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1236 KB Output is correct
2 Correct 1 ms 1300 KB Output is correct
3 Correct 1 ms 1296 KB Output is correct
4 Correct 1 ms 1236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1236 KB Output is correct
2 Correct 1 ms 1236 KB Output is correct
3 Correct 1 ms 1236 KB Output is correct
4 Correct 1 ms 1300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1236 KB Output is correct
2 Correct 2 ms 1236 KB Output is correct
3 Correct 2 ms 1236 KB Output is correct
4 Correct 2 ms 1236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1364 KB Output is correct
2 Correct 2 ms 1236 KB Output is correct
3 Correct 3 ms 1364 KB Output is correct
4 Correct 3 ms 1296 KB Output is correct