QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#657026 | #6310. Dining Professors | Fluoresce# | WA | 5ms | 3992kb | C++20 | 1.4kb | 2024-10-19 14:04:18 | 2024-10-19 14:04:20 |
Judging History
answer
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
typedef long long ll;
typedef long double ld;
#define debug(a) cout<<a<<'\n'
#define Pll pair<ll,ll>
#define PII pair<int,int>
#define ft first
#define sd second
#define vec vector
#define pushk push_back
#define pl p<<1
#define pr p<<1|1
using namespace std;
const int N = 2e5 + 10, M = 1e4 + 10, mod = 1e9 + 7;
const ll inf = 1e18;
const ld eps = 1e-13;
int mov[4][2] = { {0,1},{1,0},{-1,0},{0,-1} }, dx, dy, _ = 1, __ = 1;
void bout(bool f) {
if (f)cout << "Yes\n";
else cout << "No\n";
}
ll n, m, k;
int a[N];
void ini() {
}
void solve() {
cin>>n>>m;
for(int i=1;i<=n;++i)cin>>a[i];
map<int,int>mp;
int x;
for(int i=2;i<n;++i){
x=a[(i+n-2)%n+1]+a[i]+a[i%n+1];
if(x==3)++mp[3];
else if(x==2)++mp[2];
else if(x==1)++mp[1];
else ++mp[0];
}
int ans=3*n;
for(int i=3;i>=0;--i){
if(mp[i]>=m){
ans-=m*(3-i);
break;
}else{
ans-=mp[i]*(3-i);
m-=mp[i];
}
}
cout<<ans;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#ifndef ONLINE_JUDGE
streambuf* cinbackup = cin.rdbuf(), * coutbackup = cout.rdbuf();
ifstream fin("in.txt");
ofstream fout("out.txt");
cin.rdbuf(fin.rdbuf());
cout.rdbuf(fout.rdbuf());
#endif
//cin >> _;
__ = _;
ini();
while (_--) {
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3612kb
input:
5 2 1 0 1 0 1
output:
13
result:
ok 1 number(s): "13"
Test #2:
score: -100
Wrong Answer
time: 5ms
memory: 3992kb
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:
279234
result:
wrong answer 1st numbers differ - expected: '279236', found: '279234'