Submission #653306

# Submission time Handle Problem Language Result Execution time Memory
653306 2022-10-26T14:03:24 Z tredsused70 Catfish Farm (IOI22_fish) C++17
6 / 100
92 ms 14632 KB
#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

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 time Memory Grader output
1 Correct 31 ms 3396 KB Output is correct
2 Correct 38 ms 3788 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Runtime error 92 ms 14632 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 63 ms 5736 KB Output is correct
3 Correct 78 ms 10000 KB Output is correct
4 Correct 36 ms 4444 KB Output is correct
5 Correct 45 ms 5208 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 32 ms 4420 KB Output is correct
13 Correct 39 ms 5272 KB Output is correct
14 Correct 33 ms 4216 KB Output is correct
15 Correct 36 ms 4748 KB Output is correct
16 Correct 32 ms 4288 KB Output is correct
17 Correct 38 ms 4604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 1 ms 340 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 1 ms 340 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 31 ms 3396 KB Output is correct
2 Correct 38 ms 3788 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Runtime error 92 ms 14632 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -