답안 #28107

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
28107 2017-07-15T10:49:34 Z EyeOfSol(#1198, tlwpdus) 개미와 비트코인 (FXCUP2_ant) C++11
1 / 1
63 ms 5208 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
ll n, l, t;

ll mokx(ll a, ll b) {
	if (a>=0) return a/b;
	return (a-b+1)/b;
}

ll loc(ll a, ll dir, ll t) {
	ll v = a+t*dir;
	if (mokx(v,l)%2) return l-(v%l+l)%l;
	return (v%l+l)%l;
}

ll arr[100100], ord[100100];
vector<ll> vec;

int main() {
	ll i;
	scanf("%lld%lld%lld",&n,&l,&t);
	for (i=0;i<n;i++) {
		char ch;
		ord[i] = i;
		scanf("%lld %c",&arr[i],&ch);
		if (ch=='L') vec.push_back(loc(arr[i],-1,t));
		else vec.push_back(loc(arr[i],1,t));
	}
	sort(ord,ord+n,[&](ll a, ll b){return arr[a]<arr[b];});
	ll id;
	scanf("%lld",&id); id--;
	ll v = vec[id];
	sort(vec.begin(),vec.end());
	for (i=0;i<vec.size();i++) {
		if (vec[i]==v) {
			printf("%lld\n",ord[i]+1);
			break;
		}
	}

    return 0;
}

Compilation message

ant.cpp: In function 'int main()':
ant.cpp:37:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (i=0;i<vec.size();i++) {
            ^
ant.cpp:24:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld%lld",&n,&l,&t);
                                ^
ant.cpp:28:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %c",&arr[i],&ch);
                               ^
ant.cpp:34:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&id); id--;
                   ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3588 KB Output is correct
2 Correct 0 ms 3588 KB Output is correct
3 Correct 0 ms 3588 KB Output is correct
4 Correct 0 ms 3588 KB Output is correct
5 Correct 0 ms 3588 KB Output is correct
6 Correct 0 ms 3728 KB Output is correct
7 Correct 0 ms 3588 KB Output is correct
8 Correct 0 ms 3728 KB Output is correct
9 Correct 0 ms 3728 KB Output is correct
10 Correct 0 ms 3728 KB Output is correct
11 Correct 0 ms 3588 KB Output is correct
12 Correct 0 ms 3728 KB Output is correct
13 Correct 46 ms 5208 KB Output is correct
14 Correct 53 ms 5208 KB Output is correct
15 Correct 39 ms 5208 KB Output is correct
16 Correct 49 ms 5208 KB Output is correct
17 Correct 53 ms 5208 KB Output is correct
18 Correct 43 ms 5208 KB Output is correct
19 Correct 63 ms 5208 KB Output is correct
20 Correct 53 ms 5208 KB Output is correct