QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#55790#2960. Social DistancingomaradwanWA 7ms13112kbC++1.4kb2022-10-15 05:55:552022-10-15 05:55:58

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-15 05:55:58]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:13112kb
  • [2022-10-15 05:55:55]
  • 提交

answer

#include <bits/stdc++.h>

#define ll long long

#define pb push_back
#define el '\n'
#define pi 3.1415926536
#define mod 1000000007

#include <sstream>

#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<typename T>
using pbds = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


int const N = 2e5+5;

map<int, int>mp;
map<int, int> freqq;
map<pair<ll, ll>, ll> mpp;
vector<pair<ll,ll>>adj[N],adj2[N];
deque<pair<int,int>>pq2;
//priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<>>pq;

int dx[] = { 1, -1,0, 0 };
int dy[] = { 0,0, 1,-1  };
int chess_x[] = { -1,-1,1,1, 1, -1, 0, 0 ,0};
int chess_y[] = { 1, -1,1,-1, 0,0, 1,-1,0 };
ll a[N];

int main()
{
    fast;
   int s,n;
   cin>>s>>n;
   for(int i=0;i<n;i++)cin>>a[i];
   int ans=0;
   for(int i=0;i<n;i++){
       if(i!=n-1 && i){
           int dif=abs(a[i]-a[i-1])-2;
           if(dif>=3) {
               ans += dif / 2;
           }
       }
       else if(i==n-1){
           int dif=abs(a[i]-a[i-1])-2;
               ans += dif / 2;
           int dif2=s-a[i]+(abs(a[0]-1));

              // if (dif2 % 2 == 1)ans += dif2 / 2;
              ans += (dif2-1) / 2;
          // cerr<<dif<<" "<<dif2<< " ";
       }
   }
   cout<<ans;

    return  0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 12924kb

input:

9 2
2 6

output:

2

result:

ok single line: '2'

Test #2:

score: 0
Accepted
time: 1ms
memory: 12944kb

input:

10 3
1 4 7

output:

1

result:

ok single line: '1'

Test #3:

score: 0
Accepted
time: 2ms
memory: 13004kb

input:

6 2
2 5

output:

0

result:

ok single line: '0'

Test #4:

score: 0
Accepted
time: 2ms
memory: 13024kb

input:

100 5
7 14 47 78 99

output:

43

result:

ok single line: '43'

Test #5:

score: 0
Accepted
time: 1ms
memory: 12928kb

input:

6 1
3

output:

2

result:

ok single line: '2'

Test #6:

score: 0
Accepted
time: 2ms
memory: 13016kb

input:

3 1
1

output:

0

result:

ok single line: '0'

Test #7:

score: 0
Accepted
time: 3ms
memory: 13016kb

input:

4 2
1 3

output:

0

result:

ok single line: '0'

Test #8:

score: 0
Accepted
time: 6ms
memory: 13028kb

input:

4 2
2 4

output:

0

result:

ok single line: '0'

Test #9:

score: 0
Accepted
time: 2ms
memory: 12880kb

input:

5 2
1 3

output:

0

result:

ok single line: '0'

Test #10:

score: 0
Accepted
time: 7ms
memory: 12948kb

input:

5 2
2 4

output:

0

result:

ok single line: '0'

Test #11:

score: 0
Accepted
time: 2ms
memory: 12928kb

input:

5 2
3 5

output:

0

result:

ok single line: '0'

Test #12:

score: 0
Accepted
time: 2ms
memory: 12920kb

input:

5 2
1 4

output:

0

result:

ok single line: '0'

Test #13:

score: 0
Accepted
time: 1ms
memory: 12940kb

input:

5 2
2 5

output:

0

result:

ok single line: '0'

Test #14:

score: 0
Accepted
time: 0ms
memory: 13020kb

input:

7 1
1

output:

2

result:

ok single line: '2'

Test #15:

score: 0
Accepted
time: 1ms
memory: 13000kb

input:

1000 1
1

output:

499

result:

ok single line: '499'

Test #16:

score: 0
Accepted
time: 1ms
memory: 13112kb

input:

1000 1
2

output:

499

result:

ok single line: '499'

Test #17:

score: -100
Wrong Answer
time: 6ms
memory: 12940kb

input:

1000 1
1000

output:

998

result:

wrong answer 1st lines differ - expected: '499', found: '998'