이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |