提出 #577230


ソースコード 拡げる

#include<bits/stdc++.h>
using namespace std;
#define FZ(n) memset((n),0,sizeof(n))
#define FMO(n) memset((n),-1,sizeof(n))
#define F first
#define S second
#define PB push_back
#define ALL(x) begin(x),end(x)
#define SZ(x) ((int)(x).size())
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
template<typename A, typename B>
ostream& operator <<(ostream &s, const pair<A,B> &p) {
  return s<<"("<<p.first<<","<<p.second<<")";
}
template<typename T>
ostream& operator <<(ostream &s, const vector<T> &c) {
  s<<"[ ";
  for (auto it : c) s << it << " ";
  s<<"]";
  return s;
}
// Let's Fight!

const int MAXN = 1024;

int N;
bool d[MAXN];
int l[MAXN];
bool used[MAXN];

int main() {
    IOS;

	cin>>N;
	for(int i=0; i<N; i++)
	{
		char c;
		cin>>c>>l[i];
		d[i] = (c == 'y');
	}

	int cost = 0;

	while(1)
	{
		int cur = -1;
		for(int i=0; i<N; i++)
		{
			if(d[i] && !used[i])
			{
				if(cur == -1 || l[i] < l[cur])
					cur = i;
			}
		}

		if(cur == -1) break;

		int lb = cur, rb = cur;
		while(lb>0 && !(!d[lb-1] && l[lb-1] >= l[cur])) lb--;
		while(rb<N-1 && !(!d[rb+1] && l[rb+1] >= l[cur])) rb++;

		cost++;
		for(int i=lb; i<=rb; i++)
			used[i] = true;
	}

	cout<<cost<<endl;

    return 0;
}

提出情報

提出日時
問題 C - Delete Files
ユーザ bcw0x1bd2
言語 C++11 (GCC 4.8.1)
得点 100
コード長 1275 Byte
結果 AC
実行時間 28 ms
メモリ 932 KiB

ジャッジ結果

セット名 All
得点 / 配点 100 / 100
結果
AC × 54
セット名 テストケース
All 00_sample_00, 00_sample_01, 00_sample_02, 01_random-small_00, 01_random-small_01, 01_random-small_02, 01_random-small_03, 01_random-small_04, 01_random-small_05, 01_random-small_06, 01_random-small_07, 01_random-small_08, 01_random-small_09, 02_random-large_00, 02_random-large_01, 02_random-large_02, 02_random-large_03, 02_random-large_04, 02_random-large_05, 02_random-large_06, 02_random-large_07, 02_random-large_08, 02_random-large_09, 03_mutual_00, 03_mutual_01, 03_mutual_02, 03_mutual_03, 03_mutual_04, 03_mutual_05, 03_mutual_06, 03_mutual_07, 03_mutual_08, 03_mutual_09, 04_all_00, 04_all_01, 04_all_02, 04_all_03, 04_all_04, 04_all_05, 04_all_06, 04_all_07, 04_all_08, 04_all_09, 05_maximal_00, 05_maximal_01, 05_maximal_02, 05_maximal_03, 05_maximal_04, 05_maximal_05, 05_maximal_06, 05_maximal_07, 05_maximal_08, 05_maximal_09, 99_handmade_00
ケース名 結果 実行時間 メモリ
00_sample_00 AC 28 ms 768 KiB
00_sample_01 AC 26 ms 732 KiB
00_sample_02 AC 26 ms 792 KiB
01_random-small_00 AC 23 ms 920 KiB
01_random-small_01 AC 25 ms 800 KiB
01_random-small_02 AC 26 ms 920 KiB
01_random-small_03 AC 26 ms 920 KiB
01_random-small_04 AC 26 ms 924 KiB
01_random-small_05 AC 27 ms 724 KiB
01_random-small_06 AC 26 ms 796 KiB
01_random-small_07 AC 26 ms 928 KiB
01_random-small_08 AC 23 ms 780 KiB
01_random-small_09 AC 25 ms 932 KiB
02_random-large_00 AC 25 ms 732 KiB
02_random-large_01 AC 28 ms 804 KiB
02_random-large_02 AC 24 ms 924 KiB
02_random-large_03 AC 25 ms 932 KiB
02_random-large_04 AC 27 ms 808 KiB
02_random-large_05 AC 27 ms 800 KiB
02_random-large_06 AC 27 ms 928 KiB
02_random-large_07 AC 25 ms 796 KiB
02_random-large_08 AC 26 ms 804 KiB
02_random-large_09 AC 26 ms 804 KiB
03_mutual_00 AC 28 ms 800 KiB
03_mutual_01 AC 27 ms 928 KiB
03_mutual_02 AC 25 ms 804 KiB
03_mutual_03 AC 26 ms 800 KiB
03_mutual_04 AC 25 ms 800 KiB
03_mutual_05 AC 27 ms 932 KiB
03_mutual_06 AC 26 ms 924 KiB
03_mutual_07 AC 26 ms 804 KiB
03_mutual_08 AC 25 ms 800 KiB
03_mutual_09 AC 24 ms 932 KiB
04_all_00 AC 26 ms 812 KiB
04_all_01 AC 26 ms 796 KiB
04_all_02 AC 26 ms 924 KiB
04_all_03 AC 26 ms 912 KiB
04_all_04 AC 26 ms 916 KiB
04_all_05 AC 24 ms 920 KiB
04_all_06 AC 24 ms 800 KiB
04_all_07 AC 23 ms 920 KiB
04_all_08 AC 26 ms 920 KiB
04_all_09 AC 26 ms 732 KiB
05_maximal_00 AC 26 ms 796 KiB
05_maximal_01 AC 24 ms 920 KiB
05_maximal_02 AC 26 ms 924 KiB
05_maximal_03 AC 27 ms 796 KiB
05_maximal_04 AC 27 ms 808 KiB
05_maximal_05 AC 26 ms 800 KiB
05_maximal_06 AC 26 ms 732 KiB
05_maximal_07 AC 27 ms 800 KiB
05_maximal_08 AC 23 ms 916 KiB
05_maximal_09 AC 26 ms 792 KiB
99_handmade_00 AC 26 ms 924 KiB