QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#250807 | #6310. Dining Professors | DepletedPrism# | WA | 2ms | 3776kb | C++17 | 1.5kb | 2023-11-13 18:10:26 | 2023-11-13 18:10:27 |
Judging History
answer
/*
* @Author: zxxzy
* @Date: 2023-06-26 23:15:27
*/
#include <iostream>
#include <algorithm>
#include <cstring>
#include <bitset>
#include <set>
#include <cmath>
#include <vector>
#include <map>
//#define int long long
#define space ' '
#define endl '\n'
#define de(x) cout<<"** "<<x<<" **"<<endl;
#define N 200005
using namespace std;
using ll=long long;
const int mod=998244353;
const int INF=0x3f3f3f3f;
const double eps=1e-6;
signed main(){
#ifdef LOCAL
freopen("D:\\code2023\\test\\input.txt", "r", stdin);
freopen("D:\\code2023\\test\\output.txt", "w", stdout);
#endif
std::ios::sync_with_stdio(false);
cin.tie(0);
int n,a;
cin>>n>>a;
vector<int> b(n);
for(int i=0;i<n;i++){
cin>>b[i];
}
auto f=[&](int x){
return(x+1)%n;
};
auto g=[&](int x){
return (x-1+n)%n;
};
int ans=0;
int ss[4]={0,0,0,0};
for(int i=0;i<n;i++){
int sum=b[i]+b[f(i)]+b[g(i)];
ss[sum]++;
};
for(int i=0;i<n;i++){
if(b[i]){
ans+=3;
}
};
// de(ans)
while(a){
while(a&&ss[3]){
ans+=3;
a--;
ss[3]--;
}
while(a&&ss[2]){
ans+=2;
a--;
ss[2]--;
}
while(a&&ss[1]){
ans++;
a--;
ss[1]--;
}
}
cout<<ans<<endl;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3776kb
input:
5 2 1 0 1 0 1
output:
13
result:
ok 1 number(s): "13"
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 3772kb
input:
100000 33292 1 1 1 1 0 1 1 0 0 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 0 0 0 0 0 1 1 1 1 0 1 1 1 0 1 0 0 1 1 0 0 0 1 0 1 0 1 0 1 1 0 1 1 1 1 0 1 1 0 1 1 1 0 1 0 0 0 1 0 0 0 1 0 0 1 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 1 1 1 1 0 1 0 0 1 0 1 0 1 0 1 0 0 1 1 0 1 0 1 0 1 1 1 1 0 1 0 0 0 0 0 1 1 0 1 0 1 0 1 1 1 0 0...
output:
229166
result:
wrong answer 1st numbers differ - expected: '279236', found: '229166'