Submission #157325

#TimeUsernameProblemLanguageResultExecution timeMemory
157325karma스트랩 (JOI14_straps)C++14
100 / 100
26 ms16120 KiB
#include<bits/stdc++.h>
#define FileName      "test"
#define ll            long long
#define pb            emplace_back
#define deg           first
#define c             second

using namespace std;

typedef pair<int, int> pii;
const int N = int(2e3) + 2;
const int oo = int(2e9) + 7;

int f[N][N], a[N];
int n, res = 0, nxt;
pii val[N];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    if(fopen(FileName".inp", "r")) {
       freopen(FileName".inp", "r", stdin);
       freopen(FileName".out", "w", stdout);
    }
    cin >> n;
    for(int i = 1; i <= n; ++i) cin >> val[i].deg >> val[i].c;
    sort(val + 1, val + n + 1);
    for(int i = 1; i <= n; ++i) {
       for(int j = 0; j <= n; ++j) {
           f[i][j] = max(f[i - 1][j], (j ? f[i - 1][min(j - 1 + val[i].deg, n)] + val[i].c: 0));
       }
    }
    cout << f[n][1];
}

Compilation message (stderr)

straps.cpp: In function 'int main()':
straps.cpp:23:15: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
        freopen(FileName".inp", "r", stdin);
        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
straps.cpp:24:15: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
        freopen(FileName".out", "w", stdout);
        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...