Submission #110002

# Submission time Handle Problem Language Result Execution time Memory
110002 2019-05-08T15:41:55 Z Arturgo Coin Collecting (JOI19_ho_t4) C++14
0 / 100
3 ms 384 KB
#include <iostream>
#include <vector>
using namespace std;

int nbIci[2][100000];

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

  long long totalDist = 0;
  for(int iPiece = 0;iPiece < 2 * nbCols;iPiece++) {
    int col, lig;
    cin >> col >> lig;

    int ncol = max(1, min(nbCols, col));
    int nlig = max(1, min(2, lig));
    totalDist += abs(lig - nlig) + abs(col - ncol);
    nbIci[nlig - 1][ncol - 1]++;
  }

  int somme = 0;
  for(int iPos = 0;iPos < nbCols;iPos++) {
    somme += nbIci[0][iPos];
    somme += nbIci[1][iPos];
    totalDist += abs(somme - 2 * (iPos + 1));
  }

  somme = 0;
  for(int iPos = 0;iPos < nbCols;iPos++) {
    somme += nbIci[0][iPos];
  }
  totalDist += abs(somme - nbCols);

  cout << totalDist << endl;
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 256 KB Output is correct
6 Incorrect 3 ms 384 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 256 KB Output is correct
6 Incorrect 3 ms 384 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 256 KB Output is correct
6 Incorrect 3 ms 384 KB Output isn't correct
7 Halted 0 ms 0 KB -