QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#177209#2724. Geese vs. Hawkslmeowdn0 0ms4056kbC++142.0kb2023-09-12 17:49:142023-09-12 17:49:14

Judging History

This is the latest submission verdict.

  • [2023-09-12 17:49:14]
  • Judged
  • Verdict: 0
  • Time: 0ms
  • Memory: 4056kb
  • [2023-09-12 17:49:14]
  • Submitted

answer

#include<bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define mp make_pair
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 i128; 
template<typename T,typename U>
T ceil(T x, U y) {return (x>0?(x+y-1)/y:x/y);}
template<typename T,typename U>
T floor(T x, U y) {return (x>0?x/y:(x-y+1)/y);}
template<class T,class S>
bool chmax(T &a,const S b) {return (a<b?a=b,1:0);}
template<class T,class S>
bool chmin(T &a,const S b) {return (a>b?a=b,1:0);}
int popcnt(int x) {return __builtin_popcount(x);}
int popcnt(ll x)  {return __builtin_popcountll(x);}
int topbit(int x) {return (x==0?-1:31-__builtin_clz(x));}
int topbit(ll x)  {return (x==0?-1:63-__builtin_clzll(x));}
int lowbit(int x) {return (x==0?-1:__builtin_ctz(x));}
int lowbit(ll x)  {return (x==0?-1:__builtin_ctzll(x));}

#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
typedef pair<int,int> pii; 
typedef vector<int> vi;
typedef vector<pii> vp;
typedef tuple<int,int,int> tiii;
ll read() {
  ll x=0,w=1; char c=getchar(); 
  while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
  while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();}
  return x*w;
}

const int N=1005;
int n,a[N],m,b[N],cx,cy,ans;
vi c,d;
priority_queue<int> p,q;
char s[N],t[N];

signed main() {
  n=read();
  scanf("%s",s+1);
  rep(i,1,n) a[i]=read();
  scanf("%s",t+1);
  rep(i,1,n) b[i]=read();
  rep(i,1,n) {
    if(s[i]=='W') c.eb(a[i]);
    else p.push(a[i]);
    if(t[i]=='W') d.eb(b[i]);
    else q.push(b[i]);
  }
  sort(c.begin(),c.end(),greater<int>());
  sort(d.begin(),d.end(),greater<int>());
  for(int x:c) {
    while(!q.empty()&&q.top()>=x) q.pop();
    if(q.empty()) break;
    ans+=x+q.top(); q.pop(); break;
  }
  for(int x:d) {
    while(!p.empty()&&p.top()>=x) p.pop();
    if(p.empty()) break;
    ans+=x+p.top(); p.pop(); break;
  }
  printf("%d\n",ans);
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 10
Accepted
time: 0ms
memory: 3824kb

input:

1
W
1
L
1

output:

0

result:

ok single line: '0'

Test #2:

score: 0
Accepted
time: 0ms
memory: 4056kb

input:

1
L
814908
W
135508

output:

0

result:

ok single line: '0'

Test #3:

score: -10
Wrong Answer
time: 0ms
memory: 3912kb

input:

10
LLLLLLLLLL
999999 999999 999999 999999 999999 999999 999999 999999 999999 999999
WWWWWWWWWW
1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000

output:

1999999

result:

wrong answer 1st lines differ - expected: '19999990', found: '1999999'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%