Submission #231772

# Submission time Handle Problem Language Result Execution time Memory
231772 2020-05-14T17:01:04 Z jamielim Coin Collecting (JOI19_ho_t4) C++14
0 / 100
5 ms 384 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n;
	scanf("%d",&n);
	int x[2*n],y[2*n];
	long long ans=0;
	for(int i=0;i<2*n;i++){
		scanf("%d%d",&x[i],&y[i]);
		if(x[i]<1){ans+=(long long)(1-x[i]);x[i]=1;}
		else if(x[i]>n){ans+=(long long)(x[i]-n);x[i]=n;}
		if(y[i]<1){ans+=(long long)(1-y[i]);y[i]=1;}
		else if(y[i]>2){ans+=(long long)(y[i]-2);y[i]=2;}
	}
	int c=0;
	for(int i=0;i<2*n;i++)if(y[i]==1)c++;
	ans+=(long long)abs(n-c);
	sort(x,x+2*n);
	for(int i=0;i<2*n;i++){
		ans+=(long long)abs(x[i]-(i/2+1));
	}
	printf("%lld",ans);
}

Compilation message

joi2019_ho_t4.cpp: In function 'int main()':
joi2019_ho_t4.cpp:6:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
joi2019_ho_t4.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&x[i],&y[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Incorrect 5 ms 304 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Incorrect 5 ms 304 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Incorrect 5 ms 304 KB Output isn't correct
7 Halted 0 ms 0 KB -