# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1107394 | 2024-11-01T07:35:52 Z | vjudge1 | Growing Vegetable is Fun 3 (JOI19_ho_t3) | C++17 | 1 ms | 504 KB |
#include <bits/stdc++.h> #define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define int long long using namespace std; const int N=2e5+5; const int inf=1e9; const int mod=1e9+7; const int N1=1e6+1; vector<int>v; vector<int>v1; struct edge{ int v,time; }; int dp[1001]; signed main(){ //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); int n; cin>>n; string s; cin>>s; int cnt=0; int cnt1=0; for(int i=1;i<=n;i++){ if(s[i-1]=='R'){ cnt++; }else{ cnt1++; } } if(n%2==0&&abs(cnt-cnt1)!=0||n%2==1&&abs(cnt-cnt1)!=1){ cout<<"-1"; return 0; } int j=2; int l=1; int ans1=0; int ans2=0; for(int i=1;i<=n;i++){ if(s[i-1]=='R'){ ans1+=abs(j-i); ans2+=abs(l-i); l+=2; j+=2; } } cout<<min(ans1,ans2); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Incorrect | 1 ms | 336 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Incorrect | 1 ms | 336 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 1 ms | 504 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 1 ms | 336 KB | Output is correct |
6 | Correct | 1 ms | 336 KB | Output is correct |
7 | Incorrect | 1 ms | 336 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Incorrect | 1 ms | 336 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |