Submission #704009

# Submission time Handle Problem Language Result Execution time Memory
704009 2023-03-01T11:04:53 Z thimote75 Pairs (IOI07_pairs) C++14
30 / 100
310 ms 293980 KB
#include <bits/stdc++.h>

using namespace std;

#define num long long

void run_bt1 () {
    vector<int> bit;

    int nbV;
    cin >> nbV;
    int dist;
    cin >> dist;
    int M;
    cin >> M;
    bit.resize(M + 10);

    vector<int> values;
    for (int id = 0; id < nbV; id ++) {
        int x; cin >> x;
        values.push_back(x);

        if (x - dist < 0) bit[0] ++;
        else bit[x - dist] += 1;
        if (x + dist + 1 < bit.size())
            bit[x + dist + 1] -= 1;
    }

    for (int e = 1; e < bit.size(); e ++)
        bit[e] += bit[e - 1];
    
    num result = 0;
    for (int u : values)
        result += bit[u] - 1;
    
    cout << (result >> 1);
}

int main () {
    int board_type;
    cin >> board_type;

    if (board_type == 1) run_bt1();
}

Compilation message

pairs.cpp: In function 'void run_bt1()':
pairs.cpp:26:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         if (x + dist + 1 < bit.size())
      |             ~~~~~~~~~~~~~^~~~~~~~~~~~
pairs.cpp:30:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for (int e = 1; e < bit.size(); e ++)
      |                     ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 300 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 294 ms 293980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1232 KB Output is correct
2 Correct 20 ms 1204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 305 ms 275624 KB Output is correct
2 Correct 296 ms 275648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 303 ms 275628 KB Output is correct
2 Correct 310 ms 275612 KB Output is correct
3 Correct 288 ms 275616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 312 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 312 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -