# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1074803 |
2024-08-25T14:14:19 Z |
jundi |
Snail (NOI18_snail) |
C++17 |
|
2 ms |
616 KB |
#include <bits/stdc++.h>
using namespace std;
bool myCmp(int i, int j)
{ return(i>j); }
void printArray(int arr[], int size){
int i;for (i = 0; i < size; i++)
{ cout << arr[i] << " ";cout << endl; }
}//means "if n is non-zero" or true
#define asort(a,x) sort(a,a+x,myCmp)//big to small
#define pb(x) push_back(x)
#define vsort(v) sort(v.begin(),v.end())
//string=vector
#define sp " "
#define ll long long int
ll t,n;
void solve(){//谢
cin>>t>>n;ll a[n],cnt=0,tmp=0,tmp2=0,tp=n;
for(ll i=0;i<n;i++){
cin>>a[i];
tmp+=a[i];tmp2+=a[i];
if(tmp<0){ tmp=0; }
if(tmp>=t){ cout<<cnt<<" "<<i;return; }
}
if(tmp2<=0){
ll checker = 0;
for(ll j=0;j<2;j++){
for(ll i=0;i<n;i++){
checker+=a[i];
if(checker<0) {checker = 0;}
if(checker>=t){ cout<<j<<" "<<i;return;}
}
}cout<<-1<<" "<<-1;return;
}
ll highest = 0, count = tmp;
for(ll i = 0; i < n; i ++){
count += a[i];
if(highest>count)
{ tp=i; }
highest = max(highest, count);
}t-=highest;cnt=t/tmp2;cnt++;
if(t%tmp2!=0){
t-=(cnt-1)*tmp2;cnt++;
for(int i=0;i<n;i++){
t-=a[i];tp=i;
if(t<=0)
{ cout<<cnt<<" "<<tp;return; }
}
}
else{
for(int i=0;i<n;i++){
if(a[i]>0){ tp=i; }
}
}
cout<<cnt<<" "<<tp;
}
int main() {
ios::sync_with_stdio(0);cin.tie(0);
solve();cout<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
548 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
404 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
548 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
404 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
604 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
604 KB |
Output is correct |
27 |
Correct |
1 ms |
600 KB |
Output is correct |
28 |
Correct |
2 ms |
616 KB |
Output is correct |
29 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
30 |
Halted |
0 ms |
0 KB |
- |