# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
781729 | 2023-07-13T10:26:06 Z | vjudge1 | Growing Vegetable is Fun 3 (JOI19_ho_t3) | C++17 | 1 ms | 212 KB |
#include <bits/stdc++.h> using namespace std; #define int long long #define faster ios_base::sync_with_stdio(false);cin.tie(NULL); #define OYY 1000000005 #define mod 998244353 #define mid (start+end)/2 vector <int> v,v2; int32_t main(){ faster int n;cin>>n; int r=0,g=0,sr=0,sg=0; string s;cin>>s; for(int i=0;i<n;i++){ if(s[i]=='R')sr++; else sg++; } //////////////////////////// if(n%2==0 && (sr!=sg)){ cout<<-1<<'\n'; return 0; } if(n%2==1 && !(sr+1==sg || sg+1==sr)){ cout<<-1<<'\n'; return 0; } for(int i=0;i<n;i++){ if(s[i]=='R'){ v.push_back(i); } else v2.push_back(i); } ///////////////////////////////// int cev=0; for(int i=0;i<min(v.size(),v2.size());i++){ cev+=abs(v[i]-v2[i])-1; } cout<<cev<<'\n'; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Incorrect | 1 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Incorrect | 1 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Incorrect | 1 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |