답안 #886664

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
886664 2023-12-12T15:22:15 Z vjudge1 Gym Badges (NOI22_gymbadges) C++17
0 / 100
321 ms 16724 KB
#include <bits/stdc++.h>

#define int long long int
#define MP make_pair
#define REP(i,n) for(int (i) = 0; (i)<(n); (i)++)
#define pb push_back

const int N = 5e3+5;
const int MOD = 1e9+7;
const int INF = 1e17;
using namespace std;

void fastio() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
}
int n,m,q;
vector<int> dp(N, INF), dpnew(N, INF);
vector<int> L, X;
void solve() {
    cin>>n;
    L.assign(n+1, 0);
    X.assign(n+1, 0);
    REP(i,n) cin>>X[i + 1];
    REP(i,n) cin>>L[i + 1];
    dp[0] = 0;
    for(int i = 1; i<=n; i++) {
        for(int j = 0; j<=n; j++) {
            dpnew[j] = INF;
            if(j > 0 && dp[j - 1] <= L[i]) {
                dpnew[j] = min(dpnew[j], dp[j - 1] + X[i]);
            } 
            if(dp[j] <= L[i]) {
                dpnew[j] = min(dpnew[j], dp[j]);
            }
        }
        swap(dp, dpnew);
    }
    // for(int i = 0; i<=n; i++) {
    //     cout<<dp[i]<<" ";
    // }
    // cout<<"\n";
    for(int i = n; i>=0; i--) {
        if(dp[i] < INF) {
            cout<<i<<"\n";
            return;
        }
    }

}

signed main() {
    // fastio();
    solve();
}   

Compilation message

Main.cpp: In function 'void solve()':
Main.cpp:5:26: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    5 | #define REP(i,n) for(int (i) = 0; (i)<(n); (i)++)
      |                          ^
Main.cpp:24:5: note: in expansion of macro 'REP'
   24 |     REP(i,n) cin>>X[i + 1];
      |     ^~~
Main.cpp:5:26: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    5 | #define REP(i,n) for(int (i) = 0; (i)<(n); (i)++)
      |                          ^
Main.cpp:25:5: note: in expansion of macro 'REP'
   25 |     REP(i,n) cin>>L[i + 1];
      |     ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 321 ms 16724 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -