QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#332337 | #6310. Dining Professors | Scano | WA | 7ms | 3748kb | C++20 | 1.1kb | 2024-02-19 14:34:19 | 2024-02-19 14:34:19 |
Judging History
answer
#include <bits/stdc++.h>
#define sz(v) v.size()
#define forn(i,n) for(int i = 0; i < n; ++i)
#define fi first
#define se second
#define el '\n'
#define all(v) v.begin(),v.end()
#define pb push_back
#define d(x) cout << #x << " : " << x << el
using namespace std;
typedef pair<int,int> ii;
int dr[] = {1,0,-1,0};
int dc[] = {0,1,0,-1};
const int nax = 1e5 + 20;
vector<int> g[nax];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
cout << setprecision(20)<< fixed;
int n, cnt;
cin >> n >> cnt;
cnt = n - cnt;
vector<int> a(n);
vector<bool> pos(n);
int ans = 0;
forn(i,n){
cin >> a[i];
if(a[i]==1) ans += 3;
}
forn(i,n){
if(!a[(i+1)%n] && !a[i] && !a[(i-1+n)%n] && cnt){
pos[i] = 1;
--cnt;
}
}
forn(i,n){
if(!a[(i+1)%n] && a[i] && !a[(i-1+n)%n] && cnt){
pos[i] = 1;
--cnt;
}
}
forn(i,n){
if(!pos[i] && !a[i]){
pos[i] = 1;
--cnt;
}
}
forn(i,n){
if(!a[i]){
ans += (pos[i] + pos[(i+1)%n] + pos[(i-1+n)%n]);
}
}
cout << ans << el;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3748kb
input:
5 2 1 0 1 0 1
output:
13
result:
ok 1 number(s): "13"
Test #2:
score: -100
Wrong Answer
time: 7ms
memory: 3560kb
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:
274998
result:
wrong answer 1st numbers differ - expected: '279236', found: '274998'