QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#103195 | #6310. Dining Professors | Nerovix# | WA | 0ms | 3440kb | C++14 | 1.3kb | 2023-05-04 18:38:37 | 2023-05-04 18:38:37 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
// #define int ll
#define pii pair<int,int>
#define se second
#define fi first
#define mpr make_pair
#define ull unsigned long long
// const int mod=1e9+7;
const int mod=998244353;
int add(int x,int y){
x+=y;return x>=mod?x-mod:x;
}
void adto(int&x,int y){
x+=y;
x>=mod?x-=mod:x;
}
int mul(int x,int y){
return 1ll*x*y%mod;
}
int qpow(int a,int b){
int ans=1;
while(b){
if(b&1)ans=mul(ans,a);
a=mul(a,a);
b>>=1;
}
return ans;
}
const int maxn=1e6+10;
int n,a;
int b[maxn];
void solve(){
cin>>n>>a;
for(int i=1;i<=n;i++){
cin>>b[i];
}
vector<int>v;
for(int i=1;i<=n;i++){
int tmp=0;
tmp+=b[i];
tmp+=b[i%n+1];
tmp+=b[(i+n-2)%n+1];
cout<<tmp<<" \n"[i==n];
v.pb(tmp);
}
sort(v.begin(),v.end(),greater<int>());
int ans=0;
for(int i=0;i<a;i++){
ans+=v[i];
}
for(int i=a;i<v.size();i++){
ans+=3;
}
cout<<ans<<"\n";
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
int t=1;
// cin>>t;
while(t--){
solve();
}
// cerr<<1.*clock()/CLOCKS_PER_SEC<<"s...\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3440kb
input:
5 2 1 0 1 0 1
output:
2 2 1 2 2 13
result:
wrong answer 1st numbers differ - expected: '13', found: '2'