답안 #626274

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
626274 2022-08-11T10:46:00 Z sword060 메기 농장 (IOI22_fish) C++17
18 / 100
162 ms 13704 KB
#include <bits/stdc++.h>
#include "fish.h"
using namespace std;
long long dp[100005][2],ar[100005];
long long rec(int i,bool f,int m){
  if(i>=m)return 0;
  if(~dp[i][f])return dp[i][f];
  long long z=rec(i+1,0,m);
  if(!f)return dp[i][0]=max(z,rec(i+1,1,m)+ar[i]);
  if(i<m-1)return dp[i][1]=max(z,rec(i+2,0,m)+ar[i]);
  return dp[i][1]=0;
}
long long max_weights(int x,int k,vector<int> a,vector<int> b,vector<int> c){
  vector<pair<int,int>>l[2];
  long long ans=0,cur=0,cur2=0;
  bool f=1;
  for(int i=0;i<k;i++){
    l[a[i]%2].push_back({b[i],c[i]});
    if(a[i]%2)cur+=c[i];
    else cur2+=c[i];
    f&=(b[i]==0);
  }
  if(f){
    for(int i=0;i<x;i++)dp[i][0]=-1,dp[i][1]=-1,ar[i]=0;
    for(int i=0;i<k;i++)ar[a[i]]=c[i];
    return rec(0,1,x);
  }
  sort(l[0].begin(),l[0].end());
  sort(l[1].begin(),l[1].end());
  ans=cur;
  if(x<=2){
    return max(cur,cur2);
  }
  int j=0;
  for(int i=0;i<(int)l[0].size();i++){
    cur+=l[0][i].second;
    while(j<(int)l[1].size()&&l[1][j].first<=l[0][i].first){
      cur-=l[1][j].second;
      j++;
    }
    ans=max(ans,cur);
  }
  return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 3312 KB Output is correct
2 Correct 36 ms 3780 KB Output is correct
3 Correct 13 ms 10464 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 119 ms 11480 KB Output is correct
6 Correct 162 ms 11484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 76 ms 5692 KB Output is correct
3 Correct 108 ms 6732 KB Output is correct
4 Correct 30 ms 3268 KB Output is correct
5 Correct 48 ms 3772 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 7 ms 10452 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 43 ms 3268 KB Output is correct
13 Correct 36 ms 3780 KB Output is correct
14 Correct 29 ms 3088 KB Output is correct
15 Correct 47 ms 3420 KB Output is correct
16 Correct 30 ms 3152 KB Output is correct
17 Correct 35 ms 3404 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 10452 KB Output is correct
2 Correct 8 ms 10452 KB Output is correct
3 Correct 29 ms 11216 KB Output is correct
4 Correct 19 ms 11764 KB Output is correct
5 Correct 46 ms 13704 KB Output is correct
6 Correct 32 ms 13660 KB Output is correct
7 Correct 37 ms 13668 KB Output is correct
8 Correct 47 ms 13680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 252 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 252 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 252 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 10452 KB Output is correct
2 Correct 8 ms 10452 KB Output is correct
3 Correct 29 ms 11216 KB Output is correct
4 Correct 19 ms 11764 KB Output is correct
5 Correct 46 ms 13704 KB Output is correct
6 Correct 32 ms 13660 KB Output is correct
7 Correct 37 ms 13668 KB Output is correct
8 Correct 47 ms 13680 KB Output is correct
9 Incorrect 34 ms 3476 KB 1st lines differ - on the 1st token, expected: '99999', found: '50000'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 3312 KB Output is correct
2 Correct 36 ms 3780 KB Output is correct
3 Correct 13 ms 10464 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 119 ms 11480 KB Output is correct
6 Correct 162 ms 11484 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 76 ms 5692 KB Output is correct
9 Correct 108 ms 6732 KB Output is correct
10 Correct 30 ms 3268 KB Output is correct
11 Correct 48 ms 3772 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 7 ms 10452 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 43 ms 3268 KB Output is correct
19 Correct 36 ms 3780 KB Output is correct
20 Correct 29 ms 3088 KB Output is correct
21 Correct 47 ms 3420 KB Output is correct
22 Correct 30 ms 3152 KB Output is correct
23 Correct 35 ms 3404 KB Output is correct
24 Correct 10 ms 10452 KB Output is correct
25 Correct 8 ms 10452 KB Output is correct
26 Correct 29 ms 11216 KB Output is correct
27 Correct 19 ms 11764 KB Output is correct
28 Correct 46 ms 13704 KB Output is correct
29 Correct 32 ms 13660 KB Output is correct
30 Correct 37 ms 13668 KB Output is correct
31 Correct 47 ms 13680 KB Output is correct
32 Incorrect 0 ms 252 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
33 Halted 0 ms 0 KB -