Submission #653306

#TimeUsernameProblemLanguageResultExecution timeMemory
653306tredsused70Catfish Farm (IOI22_fish)C++17
6 / 100
92 ms14632 KiB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

using namespace std;

#define accelerator ios_base::sync_with_stdio(0);cin.tie(0)
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int nmax = 500011, mod = 1000000007, inf = 2000010000, key = 200003;
const ll infll = 4000000000000000000;
const ld eps = 1e-9;

ll max_weights(int n, int m, vector<int> x, vector<int> y, vector<int> w) {
    if(n == 2) {
        ll ans[2] = {0, 0};
        for(int i = 0; i < m; i++) {
            ans[x[i]] += w[i];
        }
        return max(ans[0], ans[1]);
    }
    vector<pair<int, int>> mas[2];
    for(int i = 0; i < m; i++)
        mas[x[i]].pb({y[i], w[i]});
    for(int i = 0; i < 2; i++)
        sort(mas[i].begin(), mas[i].end());
    ll ans = 0, cur = 0;
    for(auto i : mas[1])
        ans += i.se;
    cur = ans;
    mas[1].pb({n + 1, 0});
    int pos = 0;
    for(int i = 0; i < mas[1].size(); i++) {
        while(pos < mas[0].size() && mas[0][pos].fi < mas[1][i].fi) {
            cur += mas[0][pos].se;
            pos++;
        }
        ans = max(ans, cur);
        cur -= mas[1][i].se;
    }
    return ans;

}

Compilation message (stderr)

fish.cpp: In function 'll max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:39:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for(int i = 0; i < mas[1].size(); i++) {
      |                    ~~^~~~~~~~~~~~~~~
fish.cpp:40:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         while(pos < mas[0].size() && mas[0][pos].fi < mas[1][i].fi) {
      |               ~~~~^~~~~~~~~~~~~~~
#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...