Submission #110002

#TimeUsernameProblemLanguageResultExecution timeMemory
110002ArturgoCoin Collecting (JOI19_ho_t4)C++14
0 / 100
3 ms384 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...