제출 #763888

#제출 시각아이디문제언어결과실행 시간메모리
763888OrazB메기 농장 (IOI22_fish)C++17
32 / 100
1079 ms2097152 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <functional> using namespace __gnu_pbds; using namespace std; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; //Dijkstra->set //set.find_by_order(x) x-position value //set.order_of_key(x) number of strictly less elements don't need *set.?? #define N 100005 #define wr cout << "Continue debugging\n"; #define all(x) (x).begin(), (x).end() #define ll long long int #define pii pair <ll, ll> #define pb push_back #define ff first #define ss second ll max_weights(int n, int m, vector<int> x, vector<int> y, vector<int> w){ bool sub1 = 0, sub2 = 0; ll sum = 0, sum1 = 0, sum2 = 0; vector<pii> col1, col2; for (int i = 0; i < m; i++){ sub1 |= (x[i]%2); sub2 |= (x[i]>1); sum += w[i]; if (!x[i]) col1.pb({y[i], w[i]}), sum1 += w[i]; else col2.pb({y[i], w[i]}), sum2 += w[i]; } if (!sub1) return sum; if (!sub2){ if (n == 2) return max(sum1, sum2); sort(all(col1)); sort(all(col2)); ll mx = sum2; int pos = 0; for (auto i : col1){ while(pos < col2.size() and col2[pos].ff <= i.ff){ sum2 -= col2[pos].ss; pos++; } sum2 += i.ss; mx = max(mx, sum2); } return mx; } int nn = *max_element(all(y))+1; vector<vector<ll>> a(n+2, vector<ll> (nn+2, 0)); for (int i = 0; i < m; i++){ a[x[i]+1][y[i]+1] = w[i]; } for (int i = 1; i <= n; i++){ for (int j = 1; j <= nn; j++){ a[i][j] += a[i][j-1]; } } vector<vector<vector<ll>>> dp(n+1, vector<vector<ll>>(nn+1, vector<ll>(nn+1, 0))); ll ans = 0; for (int i = 2; i <= n; i++){ for (int j = 0; j <= nn; j++){ for (int k = 0; k <= nn; k++){ if (k <= j){ for (int z = 0; z <= nn; z++){ ll x = max(0ll, a[i-1][j]-a[i-1][max(z,k)]); dp[i][j][k] = max(dp[i][j][k], x+dp[i-1][k][z]); } }else{ ll mx = 0; for (int z = 0; z <= nn; z++) mx = max(mx, dp[i-1][k][z]); dp[i][j][k] = max(dp[i][j][k], mx+a[i][k]-a[i][j]); } if (i == n) ans = max(ans, dp[i][j][k]); } } } return ans; } // int main () // { // int n, m; // cin >> n >> m; // vector<int> x(m), y(m), w(m); // for (int i = 0; i < m; i++) cin >> x[i] >> y[i] >> w[i]; // cout << max_weights(n,m,x,y,w); // }

컴파일 시 표준 에러 (stderr) 메시지

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:40:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |    while(pos < col2.size() and col2[pos].ff <= i.ff){
      |          ~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...