提出 #53632552


ソースコード 拡げる

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

using namespace std;

struct card {
	int id;
	int a;
	int c;
};

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	vector<card> cards(n);
	for(int i=0; i<n; i++) {
		int a, c;
		cin>>a>>c;
		cards[i]=card{i+1, a, c};
	}
	sort(cards.begin(), cards.end(), [](const auto &l, const auto &r){return l.c < r.c;});
	vector<int> ans;

	int maxatack = 0;
	
	for(auto it = cards.begin(); it != cards.end(); ++it) {
		if(it->a > maxatack) {
			maxatack = it->a;
			ans.push_back(it->id);
		}
	}
	sort(ans.begin(), ans.end());

	cout<<ans.size()<<'\n'<<ans[0];
	for(int i=1; i<ans.size(); i++) {
		cout<<' '<<ans[i];
	}
	cout<<'\n';

	return 0;
}

提出情報

提出日時
問題 C - AtCoder Magics
ユーザ akatsuki7c8
言語 C++ 17 (gcc 12.2)
得点 350
コード長 761 Byte
結果 AC
実行時間 34 ms
メモリ 6436 KiB

コンパイルエラー

Main.cpp: In function ‘int main()’:
Main.cpp:39:23: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   39 |         for(int i=1; i<ans.size(); i++) {
      |                      ~^~~~~~~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 350 / 350
結果
AC × 3
AC × 17
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_hand_00.txt, 01_hand_01.txt, 01_hand_02.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3404 KiB
00_sample_01.txt AC 1 ms 3512 KiB
00_sample_02.txt AC 1 ms 3508 KiB
01_hand_00.txt AC 22 ms 5428 KiB
01_hand_01.txt AC 33 ms 6436 KiB
01_hand_02.txt AC 24 ms 6080 KiB
02_random_00.txt AC 25 ms 5344 KiB
02_random_01.txt AC 26 ms 5388 KiB
02_random_02.txt AC 24 ms 5380 KiB
02_random_03.txt AC 25 ms 5464 KiB
02_random_04.txt AC 24 ms 5348 KiB
02_random_05.txt AC 23 ms 5380 KiB
02_random_06.txt AC 34 ms 5496 KiB
02_random_07.txt AC 34 ms 5492 KiB
02_random_08.txt AC 34 ms 5428 KiB
02_random_09.txt AC 34 ms 5460 KiB
02_random_10.txt AC 33 ms 5388 KiB