結果

問題 No.817 Coin donation
ユーザー shirokuro_bufshirokuro_buf
提出日時 2019-04-19 22:30:17
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,400 ms / 2,000 ms
コード長 2,224 bytes
コンパイル時間 1,054 ms
コンパイル使用メモリ 82,104 KB
実行使用メモリ 4,360 KB
最終ジャッジ日時 2023-10-24 05:08:38
合計ジャッジ時間 6,178 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1,400 ms
4,348 KB
testcase_03 AC 1,282 ms
4,348 KB
testcase_04 AC 1,067 ms
4,348 KB
testcase_05 AC 19 ms
4,348 KB
testcase_06 AC 22 ms
4,348 KB
testcase_07 AC 22 ms
4,348 KB
testcase_08 AC 70 ms
4,348 KB
testcase_09 AC 24 ms
4,348 KB
testcase_10 AC 100 ms
4,360 KB
testcase_11 AC 100 ms
4,360 KB
testcase_12 AC 100 ms
4,360 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

using namespace std;

int main() {

	SINT32 N = 0;
	SINT32 M = 0;

	SINT32 cntA = 1;
	SINT32 cntB = 0;
	SINT32 cntM = 0;

	SINT32 ANS = 0;

	cin >> N;
	cin >> M;

	vector<SINT32> DATAA(N);
	vector<SINT32> DATAB(N);
	
	for (SINT32 i = 0; i < N; i++) {
		cin >> DATAA[i];
		cin >> DATAB[i];
	}
	sort(DATAA.begin(),DATAA.end());
	DATAA.emplace_back(1000000001);	//後ろに追加
	sort(DATAB.begin(),DATAB.end());



	SINT32 Plus = 1;

	for (SINT32 i = DATAA[0]-1; i < 1000000001; i++) {
		while (DATAA[cntA] == i+1) {
			Plus++;
			cntA++;
		}

		cntM = cntM + Plus;
		if (cntM >= M) {
			ANS = i+1;
			break;
		}

		while (DATAB[cntB] == i+1) {
			Plus--;
			cntB++;
		}
//		cout << Plus << endl;

	}

	cout << ANS<< endl;
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());

//	vector<vector<SINT32>> DP(N,vector<SINT32>(3)); //2次元配列

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/
0