답안 #125580

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
125580 2019-07-06T02:05:04 Z wilwxk Coin Collecting (JOI19_ho_t4) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
const int MAXN=2e3+5;
const ll INF=1e15+9;
vector<ll> v;
int n, cont;
ll respf;
 
int main() {
	scanf("%d", &n); n*=2;
	for(int i=1; i<=n; i++) {
		int a, b; scanf("%d %d", &a, &b);
		if(a<1||a>n) {
			if(a<1) respf+=1-a, a=1;
			else respf+=a-n, a=n;
		}
		if(b>=2) cont++;
		respf+=min(llabs(b-1), llabs(b-2));
		v.push_back(a);
	}
	respf+=llabs(n/2-cont);
	sort(v.begin(), v.end());


	int ind=0;
	for(int i=0; i<n; i++) {
		ll cur=i/2+1;
		// printf("adsby %d %lld //%lld\n", cur, ind, respf);
		respf+=llabs(v[ind++]-cur);
	}
 
	printf("%lld\n", respf);
}

Compilation message

joi2019_ho_t4.cpp: In function 'int main()':
joi2019_ho_t4.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n); n*=2;
  ~~~~~^~~~~~~~~~
joi2019_ho_t4.cpp:14:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int a, b; scanf("%d %d", &a, &b);
             ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Incorrect 2 ms 256 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Incorrect 2 ms 256 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Incorrect 2 ms 256 KB Output isn't correct
7 Halted 0 ms 0 KB -