Submission #53624362
Source Code Expand
#include <algorithm>
#include <climits>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define REP_(i, a_, b_, a, b, ...) \
for (int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(v) v.begin(), v.end()
using pii = pair<pair<int, int>, int>;
bool compare(const pii& x, const pii& y) {
if (x.first.first != y.first.first) {
return x.first.first > y.first.first;
}
return x.first.second < y.first.second;
}
int main() {
int N;
cin >> N;
vector<pair<pair<int, int>, int>> AC(N);
REP(i, N) {
int a, c;
cin >> a >> c;
AC[i].first = make_pair(a, c);
AC[i].second = i + 1;
}
sort(AC.begin(), AC.end(), compare);
vector<int> remaining;
int minCost = INT_MAX;
// カードを一枚ずつ処理
for (const auto& card : AC) {
// 現在のカードが捨てられないかチェック
if (card.first.second < minCost) {
remaining.push_back(card.second);
minCost = card.first.second;
}
}
// 結果の出力
sort(remaining.begin(), remaining.end());
cout << remaining.size() << endl;
string sep = "";
for (const auto& index : remaining) {
cout << sep << index;
sep = " ";
}
cout << endl;
}
Submission Info
| Submission Time |
|
| Task |
C - AtCoder Magics |
| User |
noyan |
| Language |
C++ 23 (gcc 12.2) |
| Score |
350 |
| Code Size |
1303 Byte |
| Status |
AC |
| Exec Time |
120 ms |
| Memory |
6596 KiB |
Compile Error
In file included from /usr/include/c++/12/ios:40,
from /usr/include/c++/12/ostream:38,
from /usr/include/c++/12/iostream:39,
from Main.cpp:3:
In static member function ‘static constexpr std::char_traits<char>::char_type* std::char_traits<char>::copy(char_type*, const char_type*, std::size_t)’,
inlined from ‘static constexpr void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_S_copy(_CharT*, const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12/bits/basic_string.h:423:21,
inlined from ‘static constexpr void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_S_copy(_CharT*, const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12/bits/basic_string.h:418:7,
inlined from ‘constexpr std::__cxx11::basic_string<_CharT, _Traits, _Allocator>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_replace(size_type, size_type, const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12/bits/basic_string.tcc:532:22,
inlined from ‘constexpr std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::assign(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12/bits/basic_string.h:1647:19,
inlined from ‘constexpr std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12/bits/basic_string.h:815:28,
inlined from ‘int main()’ at Main.cpp:50:11:
/usr/include/c++/12/bits/char_traits.h:431:56: warning: ‘void* __builtin_memcpy(void*, const void*, long unsigned int)’ accessing 9223372036854775810 or more bytes at offsets -4611686018427387902 and [-4611686018427387903, 4611686018427387904] may overlap up to 9223372036854775813 bytes at offset -3 [-Wrestrict]
431 | return static_cast<char_type*>(__builtin_memcpy(__s1, __s2, __n));
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
350 / 350 |
| Status |
|
|
| Set Name |
Test Cases |
| 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 |
| Case Name |
Status |
Exec Time |
Memory |
| 00_sample_00.txt |
AC |
1 ms |
3464 KiB |
| 00_sample_01.txt |
AC |
1 ms |
3368 KiB |
| 00_sample_02.txt |
AC |
1 ms |
3484 KiB |
| 01_hand_00.txt |
AC |
102 ms |
5448 KiB |
| 01_hand_01.txt |
AC |
120 ms |
6596 KiB |
| 01_hand_02.txt |
AC |
77 ms |
6204 KiB |
| 02_random_00.txt |
AC |
101 ms |
5492 KiB |
| 02_random_01.txt |
AC |
101 ms |
5568 KiB |
| 02_random_02.txt |
AC |
101 ms |
5536 KiB |
| 02_random_03.txt |
AC |
101 ms |
5436 KiB |
| 02_random_04.txt |
AC |
103 ms |
5440 KiB |
| 02_random_05.txt |
AC |
101 ms |
5436 KiB |
| 02_random_06.txt |
AC |
102 ms |
5452 KiB |
| 02_random_07.txt |
AC |
101 ms |
5548 KiB |
| 02_random_08.txt |
AC |
101 ms |
5548 KiB |
| 02_random_09.txt |
AC |
101 ms |
5572 KiB |
| 02_random_10.txt |
AC |
102 ms |
5416 KiB |