Submission #128453

# Submission time Handle Problem Language Result Execution time Memory
128453 2019-07-11T00:00:34 Z dragonslayerit Coin Collecting (JOI19_ho_t4) C++14
0 / 100
2 ms 376 KB
#include <cstdio>
#include <algorithm>
#include <stdint.h>

struct Point{
  int64_t x,y;
  void read(){
    scanf("%ld %ld",&x,&y);
  }
  bool operator<(Point p)const{
    return x<p.x;
  }
}ps[200005];

int main(){
  int N;
  scanf("%d",&N);
  for(int i=0;i<N*2;i++){
    ps[i].read();
  }
  std::sort(ps,ps+N*2);
  int64_t cost=0;
  for(int i=0;i<N*2;i++){
    int64_t x=i/2+1;
    cost+=std::abs(ps[i].x-x);
    ps[i].x=x;
    std::swap(ps[i].x,ps[i].y);
  }
  for(int i=0;i<N;i++){
    std::sort(ps+i*2,ps+(i+1)*2);
    cost+=std::abs(ps[i*2].x-1);
    cost+=std::abs(ps[i*2+1].x-2);
  }
  printf("%ld\n",cost);
  return 0;
}

Compilation message

joi2019_ho_t4.cpp: In function 'int main()':
joi2019_ho_t4.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&N);
   ~~~~~^~~~~~~~~
joi2019_ho_t4.cpp: In member function 'void Point::read()':
joi2019_ho_t4.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%ld %ld",&x,&y);
     ~~~~~^~~~~~~~~~~~~~~~~
# 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 2 ms 252 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Incorrect 2 ms 376 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 2 ms 252 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Incorrect 2 ms 376 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 2 ms 252 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Incorrect 2 ms 376 KB Output isn't correct
7 Halted 0 ms 0 KB -