답안 #721327

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
721327 2023-04-10T16:59:37 Z Yell0 메기 농장 (IOI22_fish) C++17
23 / 100
158 ms 23888 KB
#include <bits/stdc++.h>
#define r first
#define w second
 
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MN=1e5+2;

ll max_weights(int N,int M,vector<int> X,vector<int> Y,vector<int> W) {
  vector<vector<pii>> fish(N+2);
  for(int i=0;i<M;++i) fish[X[i]+1].push_back({Y[i]+1,W[i]});

  fish[0].push_back({0,0});
  fish[N+1].push_back({0,0});
  for(int i=1;i<=N;++i) {
    fish[i].push_back({0,0});
    sort(fish[i].begin(),fish[i].end());
    for(int j=1;j<(int)fish[i].size();++j) fish[i][j].w+=fish[i][j-1].w;
  }

  auto pfx=[&](int c,int r) {
    return (upper_bound(fish[c].begin(),fish[c].end(),pii(r,INT_MAX))-1)->w;
  };

  vector<vector<int>> stops(N+2);
  stops[0].push_back(0);
  stops[N+1].push_back(0);
  for(int i=1;i<=N;++i) {
    for(pii f:fish[i-1]) stops[i].push_back(f.r);
    for(pii f:fish[i+1]) stops[i].push_back(f.r);
    sort(stops[i].begin(),stops[i].end());
    stops[i].erase(unique(stops[i].begin(),stops[i].end()),stops[i].end());
  }

  vector<ll> dp[2];
  dp[0]={0};
  dp[1]={0};
  for(int i=1;i<=N+1;++i) {
    vector<ll> ndp[2];
    ll pf=0,sf=0;
    int pfi=0,sfi=(int)stops[i-1].size()-1;
    for(int s=0;s<(int)stops[i].size();++s) {
      while(pfi<(int)stops[i-1].size()&&stops[i-1][pfi]<=stops[i][s]) {
        pf=max(pf,dp[0][pfi]-pfx(i-1,stops[i-1][pfi]));
        ++pfi;
      }
      ndp[0].push_back(max(dp[1][0],pf+pfx(i-1,stops[i][s])));
    }
    for(int s=(int)stops[i].size()-1;s>=0;--s) {
      while(sfi>=0&&stops[i-1][sfi]>=stops[i][s]) {
        sf=max(sf,max(dp[0][sfi],dp[1][sfi])+pfx(i,stops[i-1][sfi]));
        --sfi;
      }
      ndp[1].push_back(sf-pfx(i,stops[i][s]));
    }
    reverse(ndp[1].begin(),ndp[1].end());
    dp[0].clear();
    dp[1].clear();
    for(ll x:ndp[0]) dp[0].push_back(x);
    for(ll x:ndp[1]) dp[1].push_back(x);
  }

  return max(dp[0][0],dp[1][0]);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 79 ms 17736 KB 1st lines differ - on the 1st token, expected: '40313272768926', found: '2147442400'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 141 ms 22604 KB 1st lines differ - on the 1st token, expected: '40604614618209', found: '8579116350'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 11184 KB Output is correct
2 Correct 35 ms 11212 KB Output is correct
3 Correct 75 ms 12316 KB Output is correct
4 Correct 46 ms 12756 KB Output is correct
5 Correct 84 ms 15232 KB Output is correct
6 Correct 85 ms 14576 KB Output is correct
7 Correct 99 ms 15144 KB Output is correct
8 Correct 86 ms 15160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 296 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 1 ms 340 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '166586189157'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 296 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 1 ms 340 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '166586189157'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 296 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 1 ms 340 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '166586189157'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 11184 KB Output is correct
2 Correct 35 ms 11212 KB Output is correct
3 Correct 75 ms 12316 KB Output is correct
4 Correct 46 ms 12756 KB Output is correct
5 Correct 84 ms 15232 KB Output is correct
6 Correct 85 ms 14576 KB Output is correct
7 Correct 99 ms 15144 KB Output is correct
8 Correct 86 ms 15160 KB Output is correct
9 Correct 78 ms 14860 KB Output is correct
10 Correct 68 ms 11832 KB Output is correct
11 Correct 156 ms 23380 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 300 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 27 ms 11168 KB Output is correct
19 Correct 26 ms 11248 KB Output is correct
20 Correct 25 ms 11184 KB Output is correct
21 Correct 27 ms 11132 KB Output is correct
22 Correct 107 ms 16748 KB Output is correct
23 Correct 158 ms 23352 KB Output is correct
24 Correct 156 ms 23888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 79 ms 17736 KB 1st lines differ - on the 1st token, expected: '40313272768926', found: '2147442400'
2 Halted 0 ms 0 KB -