Submission #128453

#TimeUsernameProblemLanguageResultExecution timeMemory
128453dragonslayeritCoin Collecting (JOI19_ho_t4)C++14
0 / 100
2 ms376 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...