Submission #1074670

# Submission time Handle Problem Language Result Execution time Memory
1074670 2024-08-25T12:04:53 Z jundi Snail (NOI18_snail) C++17
Compilation error
0 ms 0 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 intll t,n;void solve(){	cin>>t>>n;ll a[n],cnt=0,tmp=0,tp=n;	for(ll i=0;i<n;i++)	{ cin>>a[i]; }	for(int i=0;i<n;i++){		tmp+=a[i];		if(tmp<0){ tmp=0; }		if(tmp>=t)		{ cout<<cnt<<" "<<i;return; }	}if(tmp<=0){ cout<<-1<<" "<<-1;return; }	t-=tmp;	while(t>0){		cnt++;		if(t-tmp>0){ t-=tmp; }		else{			for(int i=0;i<n;i++){				t-=a[i];tp=i;				if(t<=0)				{ cout<<cnt<<" "<<i;return; }			}		}			}cout<<cnt<<" "<<tp;}int main() {	ios::sync_with_stdio(0);cin.tie(0);	solve();cout<<endl;	return 0;}

Compilation message

snail.cpp:1:31: warning: extra tokens at end of #include directive
    1 | #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 intll t,n;void solve(){ cin>>t>>n;ll a[n],cnt=0,tmp=0,tp=n; for(ll i=0;i<n;i++) { cin>>a[i]; } for(int i=0;i<n;i++){  tmp+=a[i];  if(tmp<0){ tmp=0; }  if(tmp>=t)  { cout<<cnt<<" "<<i;return; } }if(tmp<=0){ cout<<-1<<" "<<-1;return; } t-=tmp; while(t>0){  cnt++;  if(t-tmp>0){ t-=tmp; }  else{   for(int i=0;i<n;i++){    t-=a[i];tp=i;    if(t<=0)    { cout<<cnt<<" "<<i;return; }   }  }   }cout<<cnt<<" "<<tp;}int main() { ios::sync_with_stdio(0);cin.tie(0); solve();cout<<endl; return 0;}
      |                               ^~~~~~~~~
snail.cpp:1:10: fatal error: bits/stdc++.h>usin: No such file or directory
    1 | #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 intll t,n;void solve(){ cin>>t>>n;ll a[n],cnt=0,tmp=0,tp=n; for(ll i=0;i<n;i++) { cin>>a[i]; } for(int i=0;i<n;i++){  tmp+=a[i];  if(tmp<0){ tmp=0; }  if(tmp>=t)  { cout<<cnt<<" "<<i;return; } }if(tmp<=0){ cout<<-1<<" "<<-1;return; } t-=tmp; while(t>0){  cnt++;  if(t-tmp>0){ t-=tmp; }  else{   for(int i=0;i<n;i++){    t-=a[i];tp=i;    if(t<=0)    { cout<<cnt<<" "<<i;return; }   }  }   }cout<<cnt<<" "<<tp;}int main() { ios::sync_with_stdio(0);cin.tie(0); solve();cout<<endl; return 0;}
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.