提出 #30489569
ソースコード 拡げる
#include<bits/stdc++.h>
const double pi = acos(-1.0);
using namespace std;
//using namespace __gnu_pbds;
#define endl '\n'
#define sl(n) scanf("%lld",&n)
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int, int>
#define f(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
#define rf(i,a,b) for(ll i = (ll)(a); i > (ll)(b); i--)
#define ms(a,b) memset((a),(b),sizeof(a))
#define abs(x) ((x<0)?(-(x)):(x))
#define MAX 200005
#define inf LLONG_MAX
#define ninf LLONG_MIN
#define MIN INT_MIN
#define yeet return 0;
#define tihs if(fopen("input.txt","r"))freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long MAX2(long long a, long long b) {return (a) > (b) ? (a) : (b);}
inline long long MAX3(long long a, long long b, long long c) {return (a) > (b) ? ((a) > (c) ? (a) : (c)) : ((b) > (c) ? (b) : (c));}
inline long long MIN2(long long a, long long b) {return (a) < (b) ? (a) : (b);}
inline long long MIN3(long long a, long long b, long long c) {return (a) < (b) ? ((a) < (c) ? (a) : (c)) : ((b) < (c) ? (b) : (c));}
//typedef
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;
const int mod = 1e9 + 7;
int64_t extGcd(int64_t a, int64_t b, int64_t& x, int64_t& y) {if (!a) {x = 0; y = 1; return b;} int64_t x1, y1; int64_t d = extGcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return d;}
inline ll addmod(ll a, ll b) {a = a % mod + b % mod; if (a > mod)a %= mod; return a;}
inline ll submod(ll a, ll b) {a = a % mod - b % mod; if (a < 0)a += mod; return a;}
inline ll mulmod(ll a, ll b) {return (a % mod * b % mod) % mod;}
int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
inline ll exp(ll a, ll b) {if (a == 0)return 0ll; ll r = 1LL; while (b > 0) {if (b & 1) {r = r * (a % mod); r = (r + mod) % mod;} b /= 2; a = (a % mod) * (a % mod); a = (a + mod) % mod;} return (r + mod) % mod;}
ll gcd(ll a, ll b) {if (b == 0)return a; if (a == 0)return b; return gcd(b, a % b);}
uint32 setbits(ll n) {uint32 count = 0; while (n) {n &= (n - 1); count++;} return count; }
// ll f[MAX];
// ll iv[MAX];
// ll C(ll n, ll r) {
// if (n < r)return 0;
// ll ans = (f[n] % mod * iv[r] % mod) % mod;
// ans = (ans % mod * iv[n - r] % mod) % mod;
// return ans % mod;
// }
// void init() {
// f[0] = 1;
// iv[0] = 1;
// f(i, 1, MAX)f[i] = (i * f[i - 1]) % mod;
// iv[MAX - 1] = exp(f[MAX - 1], mod - 2);
// for (int i = MAX - 2; i >= 0; --i)iv[i] = (iv[i + 1] * (i + 1)) % mod;
// }
////****************************************************************************************************************************************************************************************************************////
bool cmp(pair<char,pair<ll,ll>> &a, pair<char, pair<ll,ll>> &b) {
if(a.se.fi == b.se.fi)return a.fi<b.fi;
return a.se.fi>b.se.fi;
}
int main() {
tihs;
fast_io;
int t;
// cin >> t;
t = 1;
while (t--) {
int n,m;
cin>>n>>m;
vector<pair<char,pair<ll,ll>>>li;
pair<ll,ll> a[n];
pair<ll,ll> b[m];
f(i,0,n)cin>>a[i].fi;
f(i,0,n)cin>>a[i].se;
f(i,0,m)cin>>b[i].fi;
f(i,0,m)cin>>b[i].se;
for(int i=0;i<n;i++){
li.pb({'C',a[i]});
}
f(i,0,m)li.pb({'B',b[i]});
sort(li.begin(), li.end(),cmp);
bool flag=true;
multiset<ll>avail;
// for(int i=0;i<n+m;i++){
// cout<<li[i].fi<<" "<<li[i].se.fi<<" "<<li[i].se.se<<endl;
// }
for(int i=0;i<li.size();i++){
if(li[i].fi=='B'){
avail.insert(li[i].se.se);
} else{
ll curr = li[i].se.se;
auto it = avail.lower_bound(curr);
if(it==avail.end()){
flag=false;
break;
} else{
avail.erase(it);
}
}
}
if(flag)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
return 0;
}
提出情報
コンパイルエラー
./Main.cpp: In function ‘int main()’:
./Main.cpp:104:15: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::pair<char, std::pair<long long int, long long int> > >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
104 | for(int i=0;i<li.size();i++){
| ~^~~~~~~~~~
./Main.cpp:25:47: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
25 | #define tihs if(fopen("input.txt","r"))freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
./Main.cpp:78:2: note: in expansion of macro ‘tihs’
78 | tihs;
| ^~~~
./Main.cpp:25:80: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
25 | #define tihs if(fopen("input.txt","r"))freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
./Main.cpp:78:2: note: in expansion of macro ‘tihs’
78 | tihs;
| ^~~~
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
500 / 500 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
example0.txt, example1.txt, example2.txt, example3.txt |
| All |
000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, 041.txt, example0.txt, example1.txt, example2.txt, example3.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 000.txt |
AC |
105 ms |
20168 KiB |
| 001.txt |
AC |
94 ms |
20048 KiB |
| 002.txt |
AC |
123 ms |
20584 KiB |
| 003.txt |
AC |
114 ms |
20588 KiB |
| 004.txt |
AC |
133 ms |
21056 KiB |
| 005.txt |
AC |
122 ms |
21164 KiB |
| 006.txt |
AC |
122 ms |
20176 KiB |
| 007.txt |
AC |
105 ms |
20040 KiB |
| 008.txt |
AC |
130 ms |
20588 KiB |
| 009.txt |
AC |
110 ms |
20564 KiB |
| 010.txt |
AC |
131 ms |
21104 KiB |
| 011.txt |
AC |
121 ms |
21052 KiB |
| 012.txt |
AC |
171 ms |
28188 KiB |
| 013.txt |
AC |
131 ms |
21732 KiB |
| 014.txt |
AC |
171 ms |
28236 KiB |
| 015.txt |
AC |
125 ms |
21604 KiB |
| 016.txt |
AC |
171 ms |
28192 KiB |
| 017.txt |
AC |
132 ms |
21600 KiB |
| 018.txt |
AC |
174 ms |
28244 KiB |
| 019.txt |
AC |
128 ms |
21724 KiB |
| 020.txt |
AC |
173 ms |
28184 KiB |
| 021.txt |
AC |
134 ms |
21608 KiB |
| 022.txt |
AC |
171 ms |
28112 KiB |
| 023.txt |
AC |
129 ms |
21788 KiB |
| 024.txt |
AC |
172 ms |
28112 KiB |
| 025.txt |
AC |
132 ms |
21608 KiB |
| 026.txt |
AC |
173 ms |
28292 KiB |
| 027.txt |
AC |
132 ms |
21628 KiB |
| 028.txt |
AC |
3 ms |
3608 KiB |
| 029.txt |
AC |
3 ms |
3564 KiB |
| 030.txt |
AC |
124 ms |
28240 KiB |
| 031.txt |
AC |
73 ms |
21756 KiB |
| 032.txt |
AC |
149 ms |
28160 KiB |
| 033.txt |
AC |
147 ms |
28184 KiB |
| 034.txt |
AC |
103 ms |
20160 KiB |
| 035.txt |
AC |
132 ms |
20236 KiB |
| 036.txt |
AC |
109 ms |
20080 KiB |
| 037.txt |
AC |
76 ms |
12924 KiB |
| 038.txt |
AC |
123 ms |
19804 KiB |
| 039.txt |
AC |
92 ms |
19852 KiB |
| 040.txt |
AC |
141 ms |
20872 KiB |
| 041.txt |
AC |
112 ms |
20952 KiB |
| example0.txt |
AC |
3 ms |
3612 KiB |
| example1.txt |
AC |
2 ms |
3608 KiB |
| example2.txt |
AC |
2 ms |
3568 KiB |
| example3.txt |
AC |
2 ms |
3548 KiB |