답안 #546013

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
546013 2022-04-06T04:07:11 Z tmn2005 JJOOII 2 (JOI20_ho_t2) C++17
0 / 100
1 ms 316 KB
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;

#define fr first
#define sc second

#define mk make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front

#define int long long
#define pii pair<int,int>
#define piii pair<int,pii>

#define all(s) s.begin(), s.end()
#define allr(s) s.rbegin(), s.rend()

#define NeedForSpeed ios::sync_with_stdio(0), cin.tie(0)
#define ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>

int n, m, k,  res = 1e9;
vector<int> a, b, c;
string p;

int get(int i, int j){
	int lb = upper_bound(all(a), i) - a.begin();
	int ub = upper_bound(all(c), j) - c.begin();
	if(lb < k || c.size() - ub < k)return 1e9;
	
	int tmp = a[lb-k];
	int cmp = c[ub+k-1];
	
	
	return cmp - tmp + 1 - k * 3;
}
void solve(){
	cin>>n>>k>>p;
	for(int i=0; i<n; i++){
		if(p[i] == 'J')a.pb(i);
		if(p[i] == 'O')b.pb(i);
		if(p[i] == 'I')c.pb(i);
	} 
	
	for(int i=0; i<b.size()-k+1; i++){
		res = min(res, get(b[i], b[i+k-1]));
	}
	cout<<res<<"\n";
}
main(){
	NeedForSpeed;
	int T = 1;
//	cin >> T;
	while(T--){
		solve();
	}
	return 0;
}

Compilation message

ho_t2.cpp: In function 'long long int get(long long int, long long int)':
ho_t2.cpp:35:29: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'long long int' [-Wsign-compare]
   35 |  if(lb < k || c.size() - ub < k)return 1e9;
      |               ~~~~~~~~~~~~~~^~~
ho_t2.cpp: In function 'void solve()':
ho_t2.cpp:51:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'long long unsigned int' [-Wsign-compare]
   51 |  for(int i=0; i<b.size()-k+1; i++){
      |               ~^~~~~~~~~~~~~
ho_t2.cpp: At global scope:
ho_t2.cpp:56:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   56 | main(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -